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
}