Entering an array into a function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
azz0r_
Forum Commoner
Posts: 27
Joined: Mon Jan 24, 2005 4:15 pm

Entering an array into a function

Post by azz0r_ »

Say I have a while loop of rows from the database and do

function post($thread) //thread being the row from the database.

How in the function would I then break up the $thread because atm it wont.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it'd be exactly like if you were accessing it inside the loop (excluding variables that are not known to it, or set before the function call)
azz0r_
Forum Commoner
Posts: 27
Joined: Mon Jan 24, 2005 4:15 pm

Post by azz0r_ »

how do you mean?

If I do $thread->post inside the function it returns nothing, even If I make $thread a global.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

post your code for the function and the while loop calling it.
azz0r_
Forum Commoner
Posts: 27
Joined: Mon Jan 24, 2005 4:15 pm

Post by azz0r_ »

Here, Ive cut alot of code out cos its huge

feyd | hey look ma,

Code: Select all

is on.[/color]
Last edited by azz0r_ on Thu Mar 10, 2005 2:04 pm, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd suggest using mysql_fetch_assoc(). I'd also suggest passing it by reference. You can lose the global for it.
Post Reply