Search
 
SCRIPT & CODE EXAMPLE
 

PHP

convert object to array laravel

$person = new stdClass();
$person->firstName = "Taylor";
$person->age = 32;

//Convert Single-Dimention Object to array
$personArray = (array) $person;

//Convert Multi-Dimentional Object to Array
$personArray = objectToArray($person);
function objectToArray ($object) {
    if(!is_object($object) && !is_array($object)){
    	return $object;
    }
    return array_map('objectToArray', (array) $object);
}
Comment

laravel transform object to array

$users = AppUser::all();
$users = $users->toArray();
Comment

laravel object to array

function objectToArray(&$object)
{
    return @json_decode(json_encode($object), true);
}
Comment

PREVIOUS NEXT
Code Example
Php :: laravel check collection has key 
Php :: option value selected in laravel blade 
Php :: php get random value from array 
Php :: centos :Install or enable PHP gd extension. 
Php :: Limit Product Name in Magento2 
Php :: wordpress get text of wordpress post 
Php :: wordpress get user by id 
Php :: php check if folder empty 
Php :: get user avatar wordpress 
Php :: add new column in existing table in laravel migration 
Php :: php set x-frame-options 
Php :: insert timestamps manually in laravel 
Php :: how to return 0 as true in laravel 
Php :: group in route in laravel 
Php :: command to run php file on chrome 
Php :: password hashing in laravel 
Php :: create a user using tinker 
Php :: php get extension from file from form submit 
Php :: wordpress echo the date in post 
Php :: non negative integer validation laravel 
Php :: WP_DEBUG enable 
Php :: convert object to array in php 
Php :: while loop php 
Php :: Invalid argument supplied for foreach() 
Php :: php session get data 
Php :: publish config laravel 
Php :: laravel migrate if not exists 
Php :: laravel group by on subquery 
Php :: get array key php 
Php :: permissions on ssh 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =