ainoy31 Posted May 29, 2008 Share Posted May 29, 2008 Hello- I have an array that is as follows: Array ( [0] => stdClass Object ( [hostname] => [value] => 66.249.66.165 [hostserial] => 3 ) [1] => stdClass Object ( [hostname] => [value] => 209.135.152.37 [hostserial] => 4 ) ) I am having an issue accessing the elements. I have tried using $array['hostserial'] and $array->hostserial. I get a notice warning of undefined index value. I am missing something here. Much appreciation. AM Link to comment https://forums.phpfreaks.com/topic/107798-array-issue/ Share on other sites More sharing options...
Gamic Posted May 29, 2008 Share Posted May 29, 2008 I think what you are saying is that you are trying to access an array of values that is stored inside an object, which is stored inside an array of objects. If my assumption is correct then I think you'd want to do something more like this: <?php echo $array[0]->hostname['value'];//should output 66.249.66.165 echo $array[0]->hostname['hostserial'];//should output 3 ?> But please correct me if I'm wrong Link to comment https://forums.phpfreaks.com/topic/107798-array-issue/#findComment-552578 Share on other sites More sharing options...
ainoy31 Posted May 29, 2008 Author Share Posted May 29, 2008 thanks for the suggestion. I tried as suggested and now getting another notice message of: Notice: Uninitialized string offset: 0 in my file. Link to comment https://forums.phpfreaks.com/topic/107798-array-issue/#findComment-552588 Share on other sites More sharing options...
ravi.kinjarapu Posted May 29, 2008 Share Posted May 29, 2008 hello, send me code .. i help u .... Thanks, Ravi Link to comment https://forums.phpfreaks.com/topic/107798-array-issue/#findComment-552598 Share on other sites More sharing options...
ainoy31 Posted May 29, 2008 Author Share Posted May 29, 2008 Ravi, I am just trying to extract data out of my array that I have listed previously. Do you have any suggestions to get the value out? Thanks. Link to comment https://forums.phpfreaks.com/topic/107798-array-issue/#findComment-552601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.