Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

associative array problem

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

associative array problem

Postby phPMaster » Wed Jul 02, 2003 2:26 am

I call a function with a parameter like this:

myFunction($myHash["keyName"]);

How can I get the keyName in the function? I've tried like this, but it didn't work:

function myFunction ($data) {
print key($data);
}
phPMaster
New php-forum User
New php-forum User
 
Posts: 4
Joined: Wed Jul 02, 2003 2:23 am

Postby liquedus » Wed Jul 02, 2003 6:00 am

when you call myFunction you are passing it the value at that index.. so the function will only recieve the value and nothing else, you would have to pass in the key as a seperate value, if you need it. :?
liquedus
php-forum Active User
php-forum Active User
 
Posts: 266
Joined: Tue Apr 08, 2003 5:18 am
Location: Ottawa, Canada


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot], Google Feedfetcher and 3 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.