1

i can't accsess to parameters of bottom array.how can i save parameters.

stdClass Object ( [MsgID] => 11604184 [UserID] => 0 [LinkID] => 0 [NumberID] => 0 [Tariff] => 0 [MsgType] => 0 [Body] => Received sms test2. [Udh] => [SendDate] => 2013-06-08T14:30:22.213 [Sender] => 9352175555 [Receiver] => 30001110000011 [FirstLocation] => 1 [CurrentLocation] => 1 [Parts] => 1 [IsFlash] => [IsRead] => 1 [IsUnicode] => [Credit] => 0 [Module] => 0 [RecCount] => 1 [RecFailed] => 0 [RecSuccess] => 0 [IsMoneyBack] => )

stdClass Object ( [MsgID] => 11603241 [UserID] => 0 [LinkID] => 0 [NumberID] => 0 [Tariff] => 0 [MsgType] => 0 [Body] => Received sms test. [Udh] => [SendDate] => 2013-06-08T14:22:43.293 [Sender] => 9352175555 [Receiver] => 30001110000011 [FirstLocation] => 1 [CurrentLocation] => 1 [Parts] => 1 [IsFlash] => [IsRead] => 1 [IsUnicode] => [Credit] => 0 [Module] => 0 [RecCount] => 1 [RecFailed] => 0 [RecSuccess] => 0 [IsMoneyBack] => ) 
slash197
  • 8,782
  • 6
  • 38
  • 68
tarannom
  • 11
  • 2
  • If you really have to access the properties of an object as though it was an associative array, then cast it to an array using `$myArray = (array) $myObject;` but why not simply access object properties as properties? `$value = $myObject->MsgID;` – Mark Baker Jun 23 '13 at 10:43

2 Answers2

2

It's not an array, it's an stdClass Object.

You can access object properties using this syntax:

echo $obj->MsgID;

Or use typecasting to convert stdClass object to array:

$array = (array)$obj;
echo $array['MsgID'];
Community
  • 1
  • 1
Hast
  • 8,664
  • 5
  • 42
  • 64
0

As a solution to your problem if you need to access the content of stdClass as an array you can typecast the object variable into array type.

E.g $a=(array)$object;

Rubin Porwal
  • 3,218
  • 1
  • 17
  • 25