Masnad Nihit Masnad Nihit - 1 year ago 108
PHP Question

getting stdclass object out of array with base64 encoded string

Hello I have a array here with std class object inside a


array(2) (
[0] => stdClass object {
ID => (string) 44
Owner => (string) 675
relatesto => (string) userid
name => (string) images.jpg
type => (string) image/jpeg
size => (string) 2424
image_heading => (string) ffffff
image => (string)
INSERT_DT => (string) 2016-11-08 13:08:25
UPDATE_DT => null
ORIG_ID => (string) 44
[1] => stdClass object {
ID => (string) 45
Owner => (string) 675
relatesto => (string) userid
name => (string) masnad.jpg
type => (string) image/jp...

I normally use
$images = json_decode(json_encode($imagez), true);
but for some odd reason it does not work, and returns
and if I even try to do it in this way
$images = json_decode(json_encode($imagez[0]), true);
I still get a
value, but normally it would get me the arrays without the stdClass object. So not sure why its going wrong. base64 encoded strings containing string in
image =>(string)

Answer Source

For this case it is better to use object notation ->. So a simple foreach will do the trick.

//Create a array
$storeimage = array();
foreach ($images as $image){
        $storeimagez[] = $image->ID;
        $storeimagez[] = $image->Owner;
        $storeimagez[] = $image->relatesto;
        // and so on 

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download