Answers for "convert array to object laravel"

PHP
9

php convert array to object

$object = (object) $array;
Posted by: Guest on March-17-2020
0

laravel array to object

public function index() {

    $user = Auth::user();
    $page = array(
        'title' => 'Hello World',
        'template' => 'welcome',
    );

    $page = (object)$page;

    return View('index', array(
        'user' => $user,
        'page' => $page,
    ));

}
Posted by: Guest on June-20-2021
0

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);
}
Posted by: Guest on November-03-2019

Code answers related to "convert array to object laravel"

Browse Popular Code Answers by Language