php - Why is preg_match_all returning two matches? -


I am trying to identify that between double quotes using string in the string using preg_match_all There is a word, but it is either a double quote of repeating results and two sets of first result, either on either side, where the string is being searched, there is only one set.

Here is my code:

  $ Str = 'test start' test match this "Test End. '; $ Groups = array ();  

and generates var dumps:

[2] {<0 array (2) {[0] = & Gt; Array (1) {[0] = & gt; String (17) "" matches this ""} [1] = & gt; Array (1) {[0] = & gt; String (15) "test this match"}}

As you can see the first array is wrong, why preg_match_all is coming back If you are using print_r instead of vardump, then you will be able to see the difference better.

array ([0] => array ([0] = & gt; "Test match From ") [1] => Array (match [0] => test)

The first string is the first and the second is your match.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -