Questions tagged as 'stdclass'

1
answer

What is the purpose of stdClass in PHP?

What is the purpose of the stdClass pre-defined class in PHP? In detail what does it do? How important is it?
asked by 04.06.2016 / 22:25
2
answers

How do I know if a stdClass is empty?

In PHP, to check if a array is empty we can use the language function (or language constructor) empty . So: $a = array(); $b = array(1, 2); var_dump(empty($a), empty($b)); // Imprime: bool(true), bool(false) But the same d...
asked by 18.10.2015 / 00:35
2
answers

Foreach with PHP StdClass

My page shows posts that have been registered to the database. Some posts have files that have been uploaded. These files are saved in server folders and the database has the table "Pivot_files" with columns ID, Post, Name and Size. $postagens...
asked by 23.11.2016 / 08:34
1
answer

error in getting values from array stdClass php

When I use echo var_dump($location); I get this: object(stdClass)#1226 (2) { ["type"]=> string(5) "Point" ["coordinates"]=> array(2) { [0]=> float(44.0928438) [1]=> float(-70.20876942) } } I tried to get the floats (44.09...
asked by 24.05.2014 / 04:10
1
answer

Get values from within stdClass array stdClass

I have this class where I can do the query and return data from an external webservice: $params = array( 'usuario' => $usuario, 'senha' => $senha, 'quantidade' => 2 ); $wsdl = 'http://xxxx.com?WSDL'; $options = array(...
asked by 28.06.2017 / 20:39
1
answer

How to convert a stdClass to array, recursively?

I have the following object: $a = new stdClass; $a->id = 1; $a->nome = 'wallace'; $a->parentes = new stdClass; $a->parentes->pai = 'Sidney'; $a->parentes->mae = 'Maria'; $a->parentes->esposa = 'Cirlene'; I know t...
asked by 18.10.2015 / 00:40
1
answer

How to change value of an object in php

I'm passing an object created in a jQuery file to php and getting it by the following code. $data = $_POST['data']; $d = json_decode($data); $user = $d->user; $season = $d->season; print_r($d); What is returning me the following:...
asked by 21.11.2015 / 23:20
2
answers

PHP - Transform object into array

I need to transform an object into an array so I can navigate through it and extract its data, even with: $array = (array) $object; But the result with a var_dump($array) is as follows, so I can not traverse it with a foreach :...
asked by 14.02.2018 / 02:38