I have a form that when a url is placed in the form and the button is clicked the URL is process and based on the pregmatch it extracts a URL. When a match is found for one of them the others return an error Notice: Undefined offset: 1 how can i make it so that if a match is found for one the others are not giving an error?
if ( !isset( $_GET['go'] ) ) return;
$userLink = $_GET['go'] ;
if ( !$userLink ) return;
$data = file_get_contents($userLink);
preg_match("@^(?:\s)*var url = '(.*)';@mi",$data, $parsed1);
preg_match("@^(?:\s)*self.location = '(.*)';@mi",$data, $parsed2);
preg_match("@^(?:\s)*window.location = \"(.*)\";@mi",$data, $parsed3);
preg_match("@^(?:\s)*Lbjs.TargetUrl = '(.*)';@mi",$data, $parsed4);
preg_match("@^(?:\s)*linkDestUrl = '(.*)';@mi",$data, $parsed5);
echo 'var.url - ' . $parsed1[1] . '<br>';
echo 'self.location - ' . $parsed2[1] . '<br>';
echo 'window.location - ' . $parsed3[1] . '<br>';
echo 'Lbjs.TargetUrl - ' . $parsed4[1] . '<br>';
echo 'linkDestUrl - ' . $parsed5[1];
I’m presuming only one of the URL types is going to match, not two or more?