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 :: php How do you remove an array element in a foreach loop? 
Php :: php unset reference 
Php :: php 8 constructor promotion 
Php :: php hash 
Php :: return view in laravel controller 
Php :: php destroy session after some time 
Php :: join multiple tables in laravel eloquent 
Php :: artisan make command 
Php :: php redirect seconds 
Php :: php clone datetime 
Php :: laravel select only some columns relationship 
Php :: laravel make component inline 
Php :: php array append 
Php :: upload a pdf file laravel 
Php :: join array in php as string 
Php :: search string inside array of objects php 
Php :: php check if post file is empty 
Php :: laravel apache public folder 
Php :: how to assign value of a js variable to a php variable 
Php :: php file extension 
Php :: laravel search query 
Php :: array_key_exists 
Php :: php convert to string 
Php :: how to create slug in laravel 
Php :: install php extensions for magento 2 
Php :: redirect in php 
Php :: failed to open stream permission denied in php 
Php :: sitemap for php website 
Php :: add array to array php 
Php :: woocommerce remove payment method when totla is 0 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =