By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 663 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

ACCESS VALUES WITHIN CLASS WITHIN AN ARRAY

P: n/a
I have the following construct (printed with print_r):

Array
(
[0]=> Classes Object
(
[_my_id] => 001
[_my_name] => John
)
[1]=> Classes Object
(
[_my_id] => 003
[_my_name] => Jill
)
)

What is the syntax to access _my_id and _my_name in for loop.

I have this but it doesn't work:
-for ($I = 0; $I < count($myarrays_name); $I++) {
print $myarrays_name[$I]=>Classes->_my_id
}

Thanks for the help.

Jun 21 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Wed, 21 Jun 2006 15:26:39 +0000, Shawn Hamzee wrote:
What is the syntax to access _my_id and _my_name in for loop.

I have this but it doesn't work:
-for ($I = 0; $I < count($myarrays_name); $I++) {
print $myarrays_name[$I]=>Classes->_my_id
}


for ($I = 0; $I < count($myarrays_name); $I++) {
print $myarrays_name[$I]->_my_id;
}

or simpler:

foreach ($myarrays_name as $obj) {
print $obj->_my_id;
}

Cheers,
Andy

--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

Jun 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.