Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php object to array

//This works best
$array = json_decode(json_encode($object), true);
Comment

object to array in php

$array = (array)$object;
Comment

object to array php

//It is verry  easy : just cast object to array
$array =  (array)$object;
Comment

convert object to array php

$array = (array) $object;
Comment

object to array php

$array = (array) $yourObject;
Comment

php convert object to array

$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

convert object to array in php

[
  {
    "userid":1122,
    "username":"testuser1122"
  },
  {
    "userid":1133,
    "username":"testuser1122"
  }
]
$json = json_decode($json_data, true);
		//or//
$json = json_decode($json_data);  
$jsonData = (array) $json;
Comment

convert object to array in php

// It will work Perfectly Fine.
$arr = json_decode(json_encode($obj), true);
Comment

object values to array php

array_values(get_object_vars($object));
Comment

PREVIOUS NEXT
Code Example
Php :: replace all php 
Php :: php echo arry 
Php :: phpunit filter 
Php :: wordpress get category page title 
Php :: how to link external php file to html 
Php :: laravel-admin Model does not exists ! 
Php :: valid number in excel php 
Php :: POP UP WITH PHP FUNCTION 
Php :: php substr remove last 4 characters 
Php :: how to set session in laravel 
Php :: php limit words 
Php :: file upload in php through ajax 
Php :: get session id in laravel 
Php :: laravel drop multiple columns 
Php :: install ext-ldap php 7.2 
Php :: remove all spaces php 
Php :: Redirect image attachment pages in Wordpress 
Php :: truncate table laravel eloquent 
Php :: create session in php 
Php :: php get first last loop 
Php :: pdo php check if row exist 
Php :: Your Composer dependencies require the following PHP extensions to be installed: curl 
Php :: fore install debian 10 php 7.3 
Php :: php chunk array 
Php :: how to print count query in php 
Php :: Allowed memory size of 1610612736 bytes exhausted 
Php :: php odd or even 
Php :: boot method laravel life cycle 
Php :: php function exists 
Php :: WP_DEBUG enable 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =