Access values within class within array

Access values within class within array

Post by Andy Jeffr » Fri, 23 Jun 2006 00:32:42



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.yqcomputer.com/ | PHP editor for Gnome 2
http://www.yqcomputer.com/ | Personal site and photos
 
 
 

1. array within an array or array name within an array?

2. Using values within arrays within a hash to gsub into an input word...

Hi there,

I'm a beginner at Ruby so please bear with me.

My question is how can I identify how many values are in an array
within my hash? Also, how can I utilize those values separately?

Here's what I have so far:

mtrules_cons = {
's' => s_sounds = %w[s c sc sch],
'f' => f_sounds = %w[f ph],
'k' => k_sounds = %w[ch c k cch qu],
'z' => z_sounds = %w[z s x],
'ch' => ch_sounds = %w[ch t tch ct],
'zh' => zh_sounds = %w[c ch sc sch sh]
}

puts mtrules_cons['s']

...prints out the values in the array s_sounds, one value on each line.
It appears that the hash has no knowledge that there's an array within
it...which, if true, means that I have no way of using each of those
values separately--like in looping processes. Am I wrong?

Let me pose this question: without accessing the array directly, is
there a way that I can pull the 3rd value out of the array associated
with the hash key 's'?

I'm hoping there's a way because I'm trying to craft a search and
replace loop which will loop through a word looking for letters which
match the hash key (i.e. 's') and replace every instance of 's' with
the each of the values in the associated array. For instance:

If I put in the word "say" I want the script to loop through that word
and give me:
Say
Cay
Scay
Schay


Any pointers on how to go about doing so? I'm stuck since I don't know
how to loop through the values in an array within a hash.

Thanks in advance!

Regards,

Abe

3. access violation when accessing public class variable from within class, but not from outside class

4. How to access all values within a structure within a cell using a colon argument

5. How to access all values within a structure within a cell using a

6. Percent of a value within all values, within a pivottable

7. initialize array within a class by a class member

8. Problems within access database,Problems within access database

9. RENEWED-- Arrays: Counting multiple values within array

10. storing variable values from within an array to outside an array

11. Rearranging array values based on location within array

12. Pass variable value into class and use as public within class

13. Array: Counting multiple values within array

14. COUNTIF a value within a range equals any value in an array/list

15. COUNTIF a value within a range equals any value in an array/li