I have seen the solution to this post: Convert a PHP object to an associative array but it doesn't work for me. I tried several ways to typecast a stdclass object to an array but with no luck. I am trying to send some data from my database to another server situated in a different country. This is the way I am trying:
This is the function:
public function update($dir, $id, $input)
{
$data = ['id'=>$id, 'data'=>$input];
$json = $this->call('PUT', '/'.$dir, $data);
return $json;
}
And this is what I am trying:
require_once('../Rest_smp.php');
$id="1366";
$data["operating_city_ids"] = [1,2,3];
$employee_array = (array) $data;
echo (new Rest_smp())->update('promoter', $id, $employee_array);
The result is this:
[871] => stdClass Object
(
[id] => 1366
[name] => NAME NAME
[username] => 145576
[email] => EMAIL@YAHOO.COM
[spi_classified] =>
[country_id] => 5
[timezone_id] => 9
[language_id] => 1
[status ] => active
[operating_city_ids] => stdClass Object
(
[1] => 123
)
[address] => CAMIL RESSU
[zip] => 000000
[phone] => 0766XXXXXX
[birth] => 1990-07-05
[gender] => female
[height] => 180
[shirt_size] => L
[shoe_size] => 42
[jeans_size] => 36
[driver_license] => yes
[employment_start_date] =>
[employment_end_date] =>
[clients] => Array
(
)
)
The problem is here:
[operating_city_ids] => stdClass Object
(
[1] => 123
)
It should be an array and the values should be 0=>1,1=>2,2=>3. They said to me that I should typecast the stdcass object but still doesn't work. Am I missing something?