Search
 
SCRIPT & CODE EXAMPLE
 

PHP

array to stdclass object php

//Array after (object)

$clasa = (object) array(
            'e1' => array('nume' => 'Nitu', 'prenume' => 'Andrei', 'sex' => 'm', 'varsta' => 23),
            'e2' => array('nume' => 'Nae', 'prenume' => 'Ionel', 'sex' => 'm', 'varsta' => 27),
            'e3' => array('nume' => 'Noman', 'prenume' => 'Alice', 'sex' => 'f', 'varsta' => 22),
            'e4' => array('nume' => 'Geangos', 'prenume' => 'Bogdan', 'sex' => 'm', 'varsta' => 23),
            'e5' => array('nume' => 'Vasile', 'prenume' => 'Mihai', 'sex' => 'm', 'varsta' => 25)
);
Comment

php object(stdclass) to array

$array = json_decode(json_encode($object), true);
Comment

convert array to stdclass object in php example

<?php
$empInfo = array(
'name'=>'John',
'address'=>'Houston',
'employment' => array(
    'id' => '1',
    'address' => 'Los Angeles'
    )
);
// or 
$obj = (obj)['name'=> 'Jone Doe'];
print_r(json_decode(json_encode($empInfo)));
Comment

PREVIOUS NEXT
Code Example
Php :: save error cakephp 2 
Php :: add dd function composer 
Php :: laravel date validation 
Php :: php current datettime us time zone 
Php :: get count of relationship table laravel 
Php :: include a page from another directory php 
Php :: get all post meta 
Php :: check if input file is set codeigniter 
Php :: laravel model quard 
Php :: header.php file how to fetch in index.php file in wordpress 
Php :: Search WordPress with custom field 
Php :: header cross origin using php only for our domains and subdomain 
Php :: link input button in php 
Php :: get logged user id laravel 
Php :: php counting number of chars excluding newlines 
Php :: php number format 2 decimal no comma 
Php :: php code to check if variable is null 
Php :: how change the languge of fie manager in laravel 
Php :: acf get sub field 
Php :: erd in phpmyadmin 
Php :: laravel read origanl value before update 
Php :: memory limit wordpress 
Php :: phpunit filter 
Php :: how to json_encode an array in php unexpected identifier 
Php :: laravel ide-helper 
Php :: file upload in php through ajax 
Php :: wordpress do shortcode 
Php :: open php ini from terminal 
Php :: laravel string builder 
Php :: Composer detected issues in your platform: Your Composer dependencies require a PHP version "= 8.0.2". 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =