Hello,

I am new to PHP language, but not to programming or Regular expressions. I am using

preg_match_all ($pattern, $file, $matches)

in my code, where $pattern contains two groups of capturing parentheses. I understand that each element of $matches[1] is an element captured by the first group of parentheses, and $matches[2] contains each element captured by the second group. My question is; I am trying to create an associative array in which each element of $matches[1] is keyed to it's corresponding $matches[2]. What is the best way to do this?

Thank you.

My question is; I am trying to create an associative array in which each element of $matches[1] is keyed to it's corresponding $matches[2]. What is the best way to do this?

Could you elaborate on that or explain in more detail because some of those terms don't make any sense.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.