Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用base64编码字符串从数组中获取stdclass对象_Php_Arrays - Fatal编程技术网

Php 使用base64编码字符串从数组中获取stdclass对象

Php 使用base64编码字符串从数组中获取stdclass对象,php,arrays,Php,Arrays,您好,我这里有一个数组,在$imagez 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

您好,我这里有一个数组,在
$imagez

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...

我通常使用
$images=json_decode(json_encode($imagez),true)
但是由于一些奇怪的原因,它不工作,并且返回
$images
null
,如果我尝试以这种方式执行
$images=json\u decode(json\u encode($imagez[0]),true)
我仍然会得到一个
null
值,但通常会得到没有stdClass对象的数组。所以我不知道为什么会出问题。base64编码字符串包含
image=>(string)

对于这种情况,最好使用对象表示法
->
。因此,一个简单的
foreach
就可以了

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

}