Reputation: 15959
Hello again Stackoverflow!
<strong>Potato</strong>
preg_match("'<strong>(.*?)</strong>'si", $source, $match);
This will return Potato
, simple regex. But here's the challange. I now have a setup like this that I want to match:
<strong>Potato</strong> Carrot
<strong>Apple</strong> Pear
<strong>Lemon</strong> Citron
And I would like to have that in an array like so:
(
'Potato' => 'Carrot',
'Apple' => 'Pear',
'Lemon' => 'Citron'
)
But I have no idea how I could approach this. Could you guys help me?
Thanks in advance!
Upvotes: 0
Views: 96
Reputation: 213223
You can use this:
preg_match("'<strong>(.*?)</strong>\s*([^<]*)'si", $source, $match);
See demo
Upvotes: 1