[英]call php array inside the function
require_once('db_lib.php');
$oDB = new db;
$result = $oDB->select('select * from tweet_urls');
while ($row = mysqli_fetch_row($result)) {
//echo $row['1'].'</br>';
echo get_follow_url($row['1']);
}
function get_follow_url($url) {
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_HEADER => false,
CURLOPT_NOBODY => true,
CURLOPT_FOLLOWLOCATION => true,
));
curl_exec($ch);
$follow_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_close($ch);
return $follow_url;
}
I extract the tweets urls from twitter and I want to change the short urls into its original long urls. 我从twitter提取了tweets url,我想将短url更改为其原始的长url。 What is wrong in my code. 我的代码有什么问题。 I call the function get_follow_url($url) inside the while loop. 我在while循环中调用函数get_follow_url($ url)。 I think I do some mistakes in calling array get_follow_url($row['1']) inside the call function . 我认为我在调用函数内部调用数组get_follow_url($ row ['1'])时犯了一些错误。
You need to use the field position which will be $row[1] without quotes. 您需要使用字段位置$ row [1](不带引号)。 If there is a field named 1 you will need to use the mysqli_fetch_assoc() or mysqli_fetch_array() methods 如果有一个名为1的字段,则需要使用mysqli_fetch_assoc()或mysqli_fetch_array()方法
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.