i have json
{"http://www.google.com/","http://www.facebook.com/","http://www.wordpress.com/",0}
How can i print like
http://www.google.com/
http://www.facebook.com/
http://www.wordpress.com/
you can use this function
function getUrls($string) {
$regex = '/https?\:\/\/[^\" ]+/i';
preg_match_all($regex, $string, $matches);
//return (array_reverse($matches[0]));
return ($matches[0]);
}
like this
$json_str = '{"http://www.google.com/","http://www.facebook.com/","http://www.wordpress.com/",0}';
$arr = getUrls($json_str);
echo "<pre>";
print_r($arr);
OUTPUT :
Array
(
[0] => http://www.google.com/
[1] => http://www.facebook.com/
[2] => http://www.wordpress.com/
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With