can i get the name of the array????

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
User avatar
montyauto
Forum Commoner
Posts: 25
Joined: Sat Jan 13, 2007 7:05 am

can i get the name of the array????

Post by montyauto »

i'm having lots of arrays with values and i have a funtion which does some operations based on the array passed as an argument..

(i.e) i want to check the name of the array and then do operations based on that.

So i want to get the name of the array passed into the funtion .

for eg:
if $cutomer = array('sefdsf','sdfsdf','sdfsdf');
i want to get the value 'customer'

is there any function to do this???
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

There's no such function.
User avatar
Gente
Forum Contributor
Posts: 252
Joined: Wed Jun 13, 2007 9:43 am
Location: Ukraine, Kharkov
Contact:

Post by Gente »

And why do you need it? Maybe there is more reasonable solution?
User avatar
mabufo
Forum Commoner
Posts: 81
Joined: Thu Jul 10, 2003 11:11 pm
Location: Orland Park, IL
Contact:

Post by mabufo »

Perhaps you could make the first entry in the array whatever sort of identifier you need. You could simply iterate through the array with a conditional statement and go from there.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I think if you look in the comments of the print_r function manual page there may be something that someone has created that does this. I have code somewhere that does what you want because I needed it for something I was working on as well. If I find it, I will post it, but search the comments in the manual because I know someone has already written something that does what you are after.
Post Reply