random - How to call the API key randomly in PHP and send to json -
please help, have 10 api keys , want phone call random "api key":
this code: $keyword = str_replace(' ', '+' , get_the_title()); $api = api1 , api2 , api3 $jsonfile='domain.com/get.php?q='.$keyword.'&key='.$api.'&format=json'; $data = json_decode(file_get_contents($jsonfile));
but... how select random api? thanks.
use rand()
function:
$api_keys = array('key1','key2','key3','key4','key5','key6','key7','key8','key9','key10'); $randkey = rand(0,10); $jsonfile='domain.com/get.php?q='.$keyword.'&key='.$api_keys[$randkey].'&format=json';
php random
No comments:
Post a Comment