1

I run preg_match_all() like this:

preg_match_all($regex, $text, $array);

And it creates a multidimensional array like this:

$array = array(
    array(1, 2...)
);

But I want it to create a simple indexed array like:

$array = array(1, 2...);

preg_match() adds an indexed array, but somehow preg_match_all() has lost the very little that remained of its mind. Why? And what's the solution?

Henrik Petterson
  • 6,862
  • 20
  • 71
  • 155

1 Answers1

0

I think you could try something like this:

 preg_match_all($regex, $text, $array, PREG_PATTERN_ORDER);
 echo "<pre>";
 print_r($output[0]);
 echo "</pre>";

You may wanna refer to this for further details: preg_match_all into simple array

Hope this helps!

Community
  • 1
  • 1
Indrasis Datta
  • 8,692
  • 2
  • 14
  • 32