Questions tagged [stdclass]

`stdClass` is php's generic empty class, kind of like Object in Java or object in Python.But not actually used as universal base class. Useful for anonymous objects, dynamic properties. It is used when casting other types to objects.

stdClass is php's generic empty class, kind of like Object in Java or object in Python.But not actually used as universal base class. Useful for anonymous objects, dynamic properties. It is used when casting other types to objects.

503 questions
0
votes
1 answer

using foreach loop how to read specific property in "stdClass"?

I have an array full of stdClass objects. I just need to unserialize a specific property in one of the objects in each index. This is what i'm trying but the object is still serialized so perhaps im just referecing it wrong. How should I be reading…
brybam
  • 5,009
  • 12
  • 51
  • 93
0
votes
1 answer

Converting Java hashmap initializer to PHP equivalent

Just curious which way is correct? // the origional JAVA method public void setRequestHeader(String key, String value) { if (this.headers == null) { this.headers = new HashMap(); } this.headers.put(key,…
ehime
  • 8,025
  • 14
  • 51
  • 110
0
votes
1 answer

Decoding StdClass in Python

I am using Python to query a WordPress.org API using urllib. WordPress.org, in turn, decides to respond with an encoded PHP StdClass object. It would be great if I were using PHP, but I must use Python. Any idea how to take this and turn it into a…
johnrom
  • 522
  • 2
  • 11
0
votes
1 answer

ezSQL Object(stdClass) Cannot use object of type stdClass as array

$db = new ezSQL_mysql($user,$pass,$db,$server); $user = $db->get_row("SELECT id,last FROM users WHERE email='$email'"); var_dump($user); The dump returns this: object(stdClass)#11 (5) { ["id"]=> string(1) "4" ["last"]=> string(19)…
Hydra IO
  • 1,537
  • 1
  • 13
  • 28
0
votes
1 answer

Iterating through stdClass object array

I am very very novice when it comes to PHP , but slowly learning :) I have a function that returns me an stdClass object with multiple arrays (see excerpt below). I would like to iterate through it with a foreach loop and do some calcultations with…
Bram
  • 11
  • 1
  • 2
0
votes
2 answers

Can't access PHP object field with period in name

I've run into an issue with PHP and object key access. I have a SimpleXMLElement that returns an array of 11 SimpleXMLElements as follows: SimpleXMLElement Object ( [Power.AssetToAssetMapping] => Array ( [0] => SimpleXMLElement…
AaplMike
  • 343
  • 1
  • 4
  • 15
0
votes
1 answer

How do I test/compare/argument match stdClass arguments to be passed to SoapClient?

My background is Java. I somehow thought diving into PHP would be fun. I have a WSDL file with a few methods defined that I need to call. Each method typically has one request and one response type defined. These types are all one or two levels…
Fredrik Wendt
  • 988
  • 1
  • 10
  • 17
0
votes
2 answers

how to access items in this stdClass Object that is return from php/soap?

i am using osticket api and had developed this function to integrate osticket into my web application: function ReadTicket($ticketID) { $osticket = new SoapClient('url'); $args = array( 'username' => 'someuser', …
hkaz
  • 1
  • 2
0
votes
2 answers

Can't get property from valid stdClass object

I'm having a very interesting problem with PHP. The following code grabs a line from a text file, decodes that text as json into an stdClass object, then puts it into an array conditionally on one of its properties. $fileStream = @fopen($fileName,…
Bloodyaugust
  • 2,463
  • 8
  • 30
  • 46
0
votes
2 answers

c++ loop data structure

Possible Duplicate: Does a standard implementation of a Circular List exist for C++? Is there ready a template class in some c++ library that is some kind of a loop: A liked list where the last node references the first one. Admittedly this…
petter
  • 1,765
  • 18
  • 22
0
votes
4 answers

I want to know how can I get the value from this print_r shown below

Here's the result of print_r($response->Items->Item->EditorialReviews->EditorialReview) Array ( [0] => stdClass Object ( [Source] => Product Description [Content] => Acer…
Sui Go
  • 463
  • 2
  • 12
  • 31
0
votes
4 answers

MySQL column into PHP array error

I have a problem with getting MySQL column into php array variable , for further foreach() cycling. Here is my code: $files=array(); $filesFetch = "SELECT FileName FROM…
Slytherin
  • 474
  • 3
  • 17
0
votes
1 answer

stsClass objects inside array

I var_dumped a variable and got this, how can i show it properly? Like,

Name: Country:

object(stdClass)#19 (3) { …
NestedWeb
  • 1,657
  • 2
  • 15
  • 31
0
votes
1 answer

how to display values of stdclass object only if they are present in another array

I have an array :- $headers=array( 'a', 'b', 'c', ); and say an object that I got from database :- $sql = 'Select * from my_table'; $views =…
user1439090
  • 792
  • 5
  • 12
  • 33
0
votes
2 answers

Strange foreach behaviour after an object casting

I get stuck with a strange PHP behaviour after a cast. Here is the code : $obj = new stdClass(); $obj->{'0'} = "test"; $array = (array)$obj; var_dump($array); This code will output : array(1) { ["0"]=> string(4) "test" } Absolutely normal. Now I…
Alain Tiemblo
  • 36,099
  • 17
  • 121
  • 153