ah ah ! No, I'd like to find a way to get the name of the array dynamicaly. something like echo $my_array.get_the_name_of_the_array();

But if you type $my_array you already know the name of the variable. What is
it *really* you are trying to achieve? When people ask these kinds of
questions it's almost always because they are on the wrong track.

> But if you type $my_array you already know the name of the variable. What
is

it *really* you are trying to achieve? When people ask these kinds of questions it's almost always because they are on the wrong track.

OK, in fact, I summed up my coding pb in order not to have a too long
message.

Actually, I've got a function with the following prototype :
function my_function ($my_array);
$my_array is an array
As this function is called from different files, the array name changes.
I'd like to avoid :
function my_function ($my_array, $array_name);
I find it "dirty"...
I'd like to use the first prototype and being able to get the name of the
array $my_array in the function.

But if you type $my_array you already know the name of the variable. What

is

it *really* you are trying to achieve? When people ask these kinds of questions it's almost always because they are on the wrong track.

Actually, I've got a function with the following prototype : function my_function ($my_array); $my_array is an array As this function is called from different files, the array name changes. I'd like to avoid : function my_function ($my_array, $array_name); I find it "dirty"... I'd like to use the first prototype and being able to get the name of the array $my_array in the function.

Hi Roland,

It's clear what you want to achieve, but why do you need to know the
variable's name?

(BTW, without somehow passing the name of the variable to your function it
is not possible)

But if you type $my_array you already know the name of the variable. What is it *really* you are trying to achieve? When people ask these kinds of questions it's almost always because they are on the wrong track.

OK, in fact, I summed up my coding pb in order not to have a too long message.

Actually, I've got a function with the following prototype : function my_function ($my_array); $my_array is an array As this function is called from different files, the array name changes. I'd like to avoid : function my_function ($my_array, $array_name); I find it "dirty"... I'd like to use the first prototype and being able to get the name of the array $my_array in the function.

Is that clearer to you ? thanks for your help,

[Obi Wan tone on]
You dont need to know the name of the variable.
[Obi Wan tone off]
You are going on the wrong track somewhere indeed. Why would you
possibly need the name of the variable? Give us the bigger picture of
what you are doing, and we can better show you a way to do it without
odd twinkets.

function arraySliceByKey($array, $key, $length)
{
return array_slice( $array, array_search($key, array_keys($array)),
$length);
}
BTW, I could not find a function to get the index of a key in an array
(needed for array_slice).
array_search and array_keys will be slow if $arraysByName is large. The
following would be a lot faster:

"roland" <ro****@no-spam.org> wrote in message
news:3f**********************@news.free.fr...

But if you type $my_array you already know the name of the variable.

What is

it *really* you are trying to achieve? When people ask these kinds of questions it's almost always because they are on the wrong track.

OK, in fact, I summed up my coding pb in order not to have a too long message.

Actually, I've got a function with the following prototype : function my_function ($my_array); $my_array is an array As this function is called from different files, the array name changes. I'd like to avoid : function my_function ($my_array, $array_name); I find it "dirty"... I'd like to use the first prototype and being able to get the name of the array $my_array in the function.

"roland" <ro****@no-spam.org> wrote in message news:<3f**********************@news.free.fr>...

But if you type $my_array you already know the name of the variable. What

is

it *really* you are trying to achieve? When people ask these kinds of questions it's almost always because they are on the wrong track.

OK, in fact, I summed up my coding pb in order not to have a too long message.

Actually, I've got a function with the following prototype : function my_function ($my_array); $my_array is an array As this function is called from different files, the array name changes. I'd like to avoid : function my_function ($my_array, $array_name); I find it "dirty"... I'd like to use the first prototype and being able to get the name of the array $my_array in the function.

pretty useless as the variable inside the function and the one you pass as
parameter to the function doesn't need to have the same name, so, I can't
see any use to know the name of the variable ... Or did I miss something :S

Savut

"roland" <ro****@no-spam.org> wrote in message
news:3f**********************@news.free.fr...

But if you type $my_array you already know the name of the variable.

What is

it *really* you are trying to achieve? When people ask these kinds of questions it's almost always because they are on the wrong track.

OK, in fact, I summed up my coding pb in order not to have a too long message.

Actually, I've got a function with the following prototype : function my_function ($my_array); $my_array is an array As this function is called from different files, the array name changes. I'd like to avoid : function my_function ($my_array, $array_name); I find it "dirty"... I'd like to use the first prototype and being able to get the name of the array $my_array in the function.