Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php convert multidimensional 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 multidimensional array to single array php

$singleArray = []; 
foreach ($parentArray as $childArray) 
{ 
    foreach ($childArray as $value) 
    { 
    $singleArray[] = $value; 
    } 
}
Comment

php Convert multidimensional array into single array

function array_flatten($array) { 
  if (!is_array($array)) { 
    return FALSE; 
  } 
  $result = array(); 
  foreach ($array as $key => $value) { 
    if (is_array($value)) { 
      $result = array_merge($result, array_flatten($value)); 
    } 
    else { 
      $result[$key] = $value; 
    } 
  } 
  return $result; 
}
Comment

PREVIOUS NEXT
Code Example
Php :: php sha512 
Php :: pdo php check if row exist 
Php :: drupal 8 get field entities 
Php :: laravel 8 $request-intersect not working 
Php :: operador in laravel 
Php :: php home url 
Php :: update json file php 
Php :: php for 
Php :: form submitting twice 
Php :: laravel add column to existing table 
Php :: storePublicly laravel with name 
Php :: how to declar a variable in php 
Php :: how to add newline in php 
Php :: get number of chars ina string php 
Php :: composer allowed memory size 
Php :: php mail success message 
Php :: laravel get url without domain in blade 
Php :: include and require in php 
Php :: php artisan down 
Php :: Database//Eloquent//Model.php laravel errror array t- string conversion 
Php :: get localstorage value in php 
Php :: get domain name laravel 
Php :: print last sql query laravel 
Php :: current URL without url site laravel 
Php :: include a file in laravel controller 
Php :: Invalid request (Unsupported SSL request) 
Php :: php remove line if it contains string 
Php :: add acf options page 
Php :: laravel get db connection info 
Php :: how to use javascript variable in php 
ADD CONTENT
Topic
Content
Source link
Name
4+4 =