473,320 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Object of class stdClass could not be converted to int

Hi,

i have a problem with the usage of stdClass.

From a SOAP based web service i get a code list as an array of
stdClass instances:

array (
0 =>
stdClass::__set_state(array(
'value' =1,
'name' ='APP_STATUS_1',
'description' ='status 1',
)),
1 =>
stdClass::__set_state(array(
'value' =2,
'name' ='APP_STATUS_1',
'description' ='status 2',
)),
2 =>
stdClass::__set_state(array(
'value' =3,
'name' ='APP_STATUS_3',
'description' ='status 3',
)),
3 =>
stdClass::__set_state(array(
'value' =4,
'name' ='APP_STATUS_ARRIVED',
'description' ='eingegangen',
)),
)

I'm looking for a specific code list item by iterating over the code
list:

foreach ($codelist as $item)
{
if ($item->value ==
$target_value) // <--- this produces the PHP
notice
{
$app_status_text = $item->description;
break;
}
}

When i run if ($item->value == $target_value) i get the PHP notice:
PHP Notice: Object of class stdClass could not be converted to int

Why PHP throws this notice. What i'm doing wrong when accesing $item-
>value.
Thanks for any anwers,
Jean Marie
Jul 23 '08 #1
2 10810
On 2008-07-23, <no**********@example.com<no**********@example.com wrote:
On Wed, 23 Jul 2008 08:00:30 -0700 (PDT), Jean Marie <je*********@gmx.net>
wrote:
>>Hi,

i have a problem with the usage of stdClass.

From a SOAP based web service i get a code list as an array of
stdClass instances:

array (
0 =>
stdClass::__set_state(array(
'value' =1,
'name' ='APP_STATUS_1',
'description' ='status 1',
)),
1 =>
stdClass::__set_state(array(
'value' =2,
'name' ='APP_STATUS_1',
'description' ='status 2',
)),
2 =>
stdClass::__set_state(array(
'value' =3,
'name' ='APP_STATUS_3',
'description' ='status 3',
)),
3 =>
stdClass::__set_state(array(
'value' =4,
'name' ='APP_STATUS_ARRIVED',
'description' ='eingegangen',
)),
)

I'm looking for a specific code list item by iterating over the code
list:

foreach ($codelist as $item)
{
if ($item->value ==
$target_value) // <--- this produces the PHP
notice
{
$app_status_text = $item->description;
break;
}
}

When i run if ($item->value == $target_value) i get the PHP notice:
PHP Notice: Object of class stdClass could not be converted to int

Why PHP throws this notice. What i'm doing wrong when accesing $item-
>>>value.

Thanks for any anwers,
Jean Marie

Have you looked at the stdClass code to see what it does with the "object"
/variable or whatever before it tries to convert it? And if the object is indeed
numeric?
The error message tends to suggest it isnt.
Maybe: $a = (array)($item); if ($a['value'] == $target_value) ...

?
--
Charles
Jul 24 '08 #2
Hi and thanks for the awnsers.

Schame on me!

The variable $item->value definitely is an integer value. Misleadingly
$target_value contained a stdClass instance.

Someday it's better to stay in bed ;-).
Thanks again and best regards
Jean Marie
Jul 25 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: BueCyb3r | last post by:
Hello, I have a problem with php 4. I create so many objects of various user defined types, and without serializing, an object of these result of stdClass type and not of the right type. So I...
3
by: Phil Powell | last post by:
if (is_array($_POST)) { foreach ($this->getAssocSectionsObjArray($key, $dbAP) as $obj) { print_r($obj); print_r(" in array? "); print_r(in_array($obj, $result)); print_r("<P>"); if...
2
by: red | last post by:
If I use PEAR to produce an accociative array from a mysql table, and display the array with print_r, it says it is an array and it displays values like a regular array: Array ( => 1 =>...
2
by: juglesh | last post by:
hello, i have a d/l'd class that gives an array which prints like this: stdClass Object ( ] => stdClass Object ( => text => => fisrt name => yes
5
by: JamesG | last post by:
Hi, I have the following object, I need to extract the SysMessage property. stdClass Object ( =stdClass Object ( =Your consignment could not be found on our system ) ) I could do this:
21
by: phpCodeHead | last post by:
Code which should allow my constructor to accept arguments: <?php class Person { function __construct($name) { $this->name = $name; } function getName()
2
by: oh.i.love.spam | last post by:
This is just an example... I don't have the access/ability to upload the actual code. Here is the meat in the XML that is returned from the $client- <VesselConfigurations...
9
ebcovert3
by: ebcovert3 | last post by:
Ok, I really need help. I am running EE (an older version admittedly) but this just started happening. I noticed a lot of spam accounts being requesting authorization to my website. I went in to the...
0
by: JonTwend | last post by:
I am working with the Twitter API and finding it great fun and generally easy to use. But I am having trouble getting to the data in the trends/current.json file. I am able to loop through the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.