I have an array of links:
('url1','url2','url3')
But sometimes it's going to be only one link e.g. ('url')
So how do i have to get the url if its only one because i'm using explode with comma?
I have an array of links:
('url1','url2','url3')
But sometimes it's going to be only one link e.g. ('url')
So how do i have to get the url if its only one because i'm using explode with comma?
$input = "('url1','url2','url3')";
preg_match_all("~'(.*?)'~", $input, $output);
var_dump( $output);
//array(2) { [0]=> array(3) { [0]=> string(6) "'url1'" [1]=> string(6) "'url2'" [2]=> string(6) "'url3'" } [1]=> array(3) { [0]=> string(4) "url1" [1]=> string(4) "url2" [2]=> string(4) "url3" } }
and
$input = "('url1')";
preg_match_all("~'(.*?)'~", $input, $output);
var_dump( $output);
//array(2) { [0]=> array(1) { [0]=> string(6) "'url1'" } [1]=> array(1) { [0]=> string(4) "url1" } }