creating object from array in php -


i need able create object array. data coming terrible api. here example of data.

array ( [0] => stdclass object     (         [no] => 1         [fl] => array             (                 [0] => stdclass object                     (                         [content] => 1505250000001141005                         [val] => accountid                     )                  [1] => stdclass object                     (                         [content] => 1505250000000091001                         [val] => smownerid                     )                  [2] => stdclass object                     (                         [content] => name here                         [val] => account owner                     ) etc... 

the [no] value insignificant. [fl] content need in object. outcome of values variable names , content values. can suggestion please?

edit think need clarify need. i'm creating class called account hold information api call in object. instantiate object call method example valuesfromarray() , pass [fl] array given api call. use [val] variable name , [content] value.

     $json_url = "api url";     //  initiate curl     $ch_curl = curl_init();     // disable ssl verification     curl_setopt($ch_curl, curlopt_ssl_verifypeer, false);     // return response, if false print response     curl_setopt($ch_curl, curlopt_returntransfer, true);     // set url     curl_setopt($ch_curl, curlopt_url, $json_url);     // execute     $result = curl_exec($ch_curl);     // closing     curl_close($ch_curl);     $data = json_decode($result, true);//true--> convert object array format 

this curl method fetch data api.use json_decode($result, true) use json decode convert object array format.

i hope usefull question.

please review,

thanks!


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -