Php object to array, Online php object to array, the following $ images is an array to convert key and value. $ What should I do if images is an object? Online
Function change ($ images, $ a = 0 ){
Foreach ($ images as $ key => $ value ){
$ Images [$ a] [$ value ['picture _ id'] = $ value ['Local _ path'];
$ Images [$ a] ['picture _ id'] = $ value ['picture _ id'];
$ A ++;
}
Return $ images;
}
$ Arry = change ($ images );
Reply to discussion (solution)
PHP built-in arrayObject class
$ Obj = new arrayObject ($ arr );
Var_dump ($ obj );
Does the database fetch data? you don't need to convert the data, just use foreach, but the object uses $ obj-> xxx to process the value.
Does the database fetch data? you don't need to convert the data, just use foreach, but the object uses $ obj-> xxx to process the value.
You are right, but the fields required by the front-end are different. you need to rename the name of foreach.