I need some help with the following code:
$myPets = “favoritePet=Lucky, Rover=dog, Lucky=cat”;
preg_match( ‘/favoritePet\=(\w+).*\1\=(\w+)/’, $myPets, $matches );
echo “My favorite pet is a “ . $matches . “ called “ . $matches . “.”;
This code displays the following output:
“My favorite pet is a cat called Lucky.”
The thing i can't understand is how the regular expression jumps past the Rover=dog part of the sting.
could someone explain how it does this?