Maybe you need preg_match_all
instead of preg_match
? A better approach:
preg_match_all("/<image:caption>.*?<\/image:caption>|<image:loc>.*?<\/image:loc>|<loc>.*?<\/loc>/", $text, $results);
$arr = array_chunk(array_map('strip_tags', $results[0]), 3);
print_r($arr);
Output:
Array
(
[0] => Array
(
[0] => /1366x768/citroen-ds-cabrio-auto-car-wallshark-com-228615.html
[1] => s/1366x768/citroen-ds/228615/citroen-ds-cabrio-auto-car-wallshark-com-228615.jpg
[2] => Citroen Ds Cabrio Auto Car Wallshark Com Walpapers
)
[1] => Array
(
[0] => /1366x768/citroen-ds-cars-citro-n-cabrio-213157.html
[1] => s/1366x768/citroen-ds/213157/citroen-ds-cars-citro-n-cabrio-213157.jpg
[2] => Citroen Ds Cars Citro N Cabrio Walpapers
)
[2] => Array
(
[0] => /1366x768/citroen-ds-citro-n-pictures-95569.html
[1] => s/1366x768/citroen-ds/95569/citroen-ds-citro-n-pictures-95569.jpg
[2] => Citroen Ds Citro N Pictures Walpapers
)
)