Hi everyone,
I need some help here with a situation where I have an array and a call to reset() or even when assigning that array to another variable the internal pointer does not point to the first element!!!
I don't know how to debug this..
the array is an object attribute and it is set from a preg_match_all( ) call.
i'm sure there are elements in the array... I don't understand :(
here is a debug result :
output content of $this->_matches :
trying to get first element :
output $this->_currentMatc h //supposedly first array element... but actually last element!
if you have any suggestions they are very very wellcome
Thank you very much!
I need some help here with a situation where I have an array and a call to reset() or even when assigning that array to another variable the internal pointer does not point to the first element!!!
I don't know how to debug this..
the array is an object attribute and it is set from a preg_match_all( ) call.
i'm sure there are elements in the array... I don't understand :(
here is a debug result :
Code:
preg_match_all($regex, $input, $this->_matches, PREG_SET_ORDER); reset($this->_matches); $a = $this->_matches;
Code:
print_r($this->_matches);
Array
(
[0] => Array
(
[0] => <a href="index.php?lien=acteur&nom=Erin Kelly">Erin Kelly</a>,
[1] => Erin Kelly
)
[1] => Array
(
[0] => <a href="index.php?lien=acteur&nom=Diane Gaidry">Diane Gaidry</a>,
[1] => Diane Gaidry
)
[2] => Array
(
[0] => <a href="index.php?lien=acteur&nom=Kevin McCarthy">Kevin McCarthy</a>,
[1] => Kevin McCarthy
)
)
Code:
(list($key, $this->_currentMatch) = each($this->_currentMatches));
Code:
print_r($this->_currentMatch);
Array
(
[0] => <a href="index.php?lien=acteur&nom=Kevin McCarthy">Kevin McCarthy</a>,
[1] => Kevin McCarthy
)
Thank you very much!
Comment