tony007
Oct 16th, 2007, 12:09 PM
HI all i am trying to pass a fuction array value from within echo statemnt but i keep getting error. I want to call the function and pass it array value and then get the returned value with in echo statement. Could any one tell me how to achive this task ?
error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in \xml2.php on line 69
pointing at :
echo " <location>" . get_link(".$videoinfo[$i]['url'].")"</location>\n";
<?
..................
$videoinfo = parse_videoinfo($xml, $fields);
//echo '<pre>' . print_r($videoinfo, true) .'</pre>';
// third, the playlist is built in an xspf format
// we'll first add an xml header and the opening tags ..
header("content-type:text/xml;charset=utf-8");
echo "<?xml version='1.0' encoding='UTF-8' ?>\n";
echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo " <trackList>\n";
for($i=0;$i<=count($videoinfo);$i++){
echo " <track>\n";
echo " <title>" . $videoinfo[$i]['title'] . "</title>\n";
echo " <creator>By me</creator>\n";
echo " <location>" . get_link(".$videoinfo[$i]['url'].")"</location>\n";
echo " </track>\n";
}
// .. and last we add the closing tags
echo " </trackList>\n";
echo "</playlist>\n";
function get_link($url){
if ($html = file_get_contents($url)){
if(preg_match_all("/\b(?:video_id)\b:.*/", $html, $matches)){
$ref = $matches[0][0];
//echo $ref.'<br>';
preg_match_all("/\'[^\'\\\\\r\n]*(?:\\\\.[^\'\\\\\r\n]*)*\'/", $ref, $match);
//video_id:'WAvj0iY1Zig',l:'142',t:'OEgsToPDskLspgdtd49MOElkAv_WEJmW',sk:'2ZgBZFfneV2DzW3Zb8g2AAC1
//print_r ($match);
$id1 = str_replace("'", "", $match[0][0]);
$id2 = str_replace("'", "", $match[0][2]);
$id3 = str_replace("'", "", $match[0][3]);
$id = $id1.'&t='.$id2.'&sk='.$id3;
//echo $id;
$url = 'http://youtube.com/get_video.php?video_id='.$id;
$url = get_headers($url);
//$url = print_r($url);
$url = $url[9];
//echo $id;
$url = substr($url,10);
$url = $url.'.flv';
//echo $url;
return $url;
}
return false;
}
}
?>
error:
Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in \xml2.php on line 69
pointing at :
echo " <location>" . get_link(".$videoinfo[$i]['url'].")"</location>\n";
<?
..................
$videoinfo = parse_videoinfo($xml, $fields);
//echo '<pre>' . print_r($videoinfo, true) .'</pre>';
// third, the playlist is built in an xspf format
// we'll first add an xml header and the opening tags ..
header("content-type:text/xml;charset=utf-8");
echo "<?xml version='1.0' encoding='UTF-8' ?>\n";
echo "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n";
echo " <trackList>\n";
for($i=0;$i<=count($videoinfo);$i++){
echo " <track>\n";
echo " <title>" . $videoinfo[$i]['title'] . "</title>\n";
echo " <creator>By me</creator>\n";
echo " <location>" . get_link(".$videoinfo[$i]['url'].")"</location>\n";
echo " </track>\n";
}
// .. and last we add the closing tags
echo " </trackList>\n";
echo "</playlist>\n";
function get_link($url){
if ($html = file_get_contents($url)){
if(preg_match_all("/\b(?:video_id)\b:.*/", $html, $matches)){
$ref = $matches[0][0];
//echo $ref.'<br>';
preg_match_all("/\'[^\'\\\\\r\n]*(?:\\\\.[^\'\\\\\r\n]*)*\'/", $ref, $match);
//video_id:'WAvj0iY1Zig',l:'142',t:'OEgsToPDskLspgdtd49MOElkAv_WEJmW',sk:'2ZgBZFfneV2DzW3Zb8g2AAC1
//print_r ($match);
$id1 = str_replace("'", "", $match[0][0]);
$id2 = str_replace("'", "", $match[0][2]);
$id3 = str_replace("'", "", $match[0][3]);
$id = $id1.'&t='.$id2.'&sk='.$id3;
//echo $id;
$url = 'http://youtube.com/get_video.php?video_id='.$id;
$url = get_headers($url);
//$url = print_r($url);
$url = $url[9];
//echo $id;
$url = substr($url,10);
$url = $url.'.flv';
//echo $url;
return $url;
}
return false;
}
}
?>