简体   繁体   中英

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. What is wrong in my code. I call the function get_follow_url($url) inside the while loop. I think I do some mistakes in calling array get_follow_url($row['1']) inside the call function .

You need to use the field position which will be $row[1] without quotes. If there is a field named 1 you will need to use the mysqli_fetch_assoc() or mysqli_fetch_array() methods

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM