Welcome Guest, Not a member yet? Register   Sign In
Calling a function from a function and passing data within same model?
#2

[eluser]rhopek[/eluser]
I've gotten things much closer now. My issue is now no longer CI-specific, but rather PHP array specific, so if this is now inappropriate to continue this thread, please let me know. If not, here's the current status:

My first function produces an array as follows:


Array
(
[0] => stdClass Object
( [id] => 1
[first_name] => John
[last_name] => Smith
[email_address] => [email protected]
)
[1] => stdClass Object
( [id] => 2
[first_name] => Jane
[last_name] => Doe
[email_address] => [email protected]
)
)



When I make the call to the second function from within the first function, I am looping through each row from the first array. On the first pass (which would be for item '0' in that initial array, I get back as my result:

Array
(
[ave_rating] => 4
)


So my question is now, how do I get the "[ave_rating] => 4" pushed into item "0" from the initial array, so that the store $data[] array now has:

Array
(
[0] => stdClass Object
( [id] => 1
[first_name] => John
[last_name] => Smith
[email_address] => [email protected]
[ave_rating] => 4
)
)

And obviously, as I keep looping, I need to keep inserting the additional element into each respective subsequent initial array items.

I have been trying to use the PHP push_array() function, but do not seem to be getting the expected results.


Messages In This Thread
Calling a function from a function and passing data within same model? - by El Forum - 10-26-2010, 12:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB