;Or statement in Regular expression not working

Tags: php
Question!

i have two html tag like :

$data ='<div style="background:url(img/img.jpg);color:blue"><div style="background-image:url(img/img2.jpg);color:black"></div></div>';

I used regular expression to get the image path like :

if( preg_match_all("/background-image:url\((.*?)\);/", $data, $backgroundImg) || preg_match_all("/background:url\((.*?)\);/", $data, $backgroundImg) )

But whenever i print the $backgroundImg it shows only the 1st one

Array
(
    [0] => Array
        (
            [0] => background-image:url(images/background.jpg);
        )

    [1] => Array
        (
            [0] => images/background.jpg
        )

)

how to get the 2nd one url also.



Answers


try this:

$data = '
By : spirit


This video can help you solving your question :)
By: admin