I'm having a difficult time appending each element in an array I have in PHP for multiple OneSignal tags. Here is the result of my current JSON encoded array:
[{"value":"[email protected]"},
{"value":"[email protected]"},
{"value":"[email protected]"}]
Desired output:
[{"key":"user_email","relation":"=","value":"[email protected]"},
{"key":"user_email","relation":"=","value":"[email protected]"},
{"key":"user_email","relation":"=","value":"[email protected]"}]
Here is my current PHP code:
$jsonData = array();
$allStaffInit = mysql_query("Select * from users");
while ($staffrow = mysql_fetch_object($allStaffInit)){
$jsonData[] = $staffrow;
}
echo json_encode($jsonData);
Any help is greatly appreciated! Thanks!
mysql_*functions. Migrate to PDO and start using Prepared, Parameterized Queries.$jsondata[] = array('key'=>$key,'relation'=>$rel,'value' => $val);