Run the array multiple times
Right now my script connects to an api and sends an sms, 1 number at a time. I want it to pull from a local sql db then repeat the response for each number in the db.
$data['post'] = array (
'_rnr_se' => $rnrse,
'phoneNumber' => '1234567890',
'text' => 开发者_开发问答'This is a test SMS!',
'id' => ''
);
// Send the SMS
$response = xcurl::fetch('api.phonegateway.com/', $data);
// Evaluate the response
$value = json_decode($response['data']);
How do I do this?
Copy from the docs
mysql_connect("localhost", "mysql_user", "mysql_password") or
die("Could not connect: " . mysql_error());
mysql_select_db("mydb");
$result = mysql_query("SELECT id, name FROM mytable");
while ($row = mysql_fetch_array($result)) {
$data['post'] = array ( '_rnr_se' => $row['number'], 'phoneNumber' => $row['phone_number'], 'text' => $row['text'], 'id' => '' );
// Send the SMS $response = xcurl::fetch('api.phonegateway.com/', $data);
// Evaluate the response $value = json_decode($response['data']);`
}
精彩评论