domingo, 10 de noviembre de 2019

object to array

217
The easiest way is to JSON-encode your object and then decode it back to an array:
$array = json_decode(json_encode($object), True);
Or if you prefer, you can traverse the object manually, too:
foreach ($object as $value) 
    $array[] = $value->post_id
$info=json_decode($reply);
$array = json_decode(json_encode($info), True);

//print_r($array);
foreach($array['result'] as $key=>$value) {
echo " $key : $value<br>";
}



Curl request using get and JSON and a Custom header

curl  -H "Content-Type: application/json"  -H "apikey:3ac" -G -d "telephone=100&call_id=555" http://api.dev.com



we use the  H  parameter  multiples time for more than 1 header

martes, 5 de noviembre de 2019

mult function to clean string

<?php

$agent_audio="Local/101@from-queue/n";

echo $d= str_replace('/','',stristr(stristr($agent_audio, '@', true),'/'));
echo "<br>"

?>

will  print  101