Get array keys when in argument in PHP

I'm passing some arrays as arguments inside a function. For example:


In that case the function gets the value stored in (2,3) but there is a way to get the keys value (2,3) from inside the function to work with? The function should use the x,y position of the value to do some calculations.



Not this way, no. If you call test($someArray[2][3]), then PHP will only pass the value, but not any reference where this value comes from. Its cleaner to pass the values separately anyway

function test($x, $y, $value) { /* do something */ }

Nope, the subscript will be performed before the function receives it.

So if your code is...

$someArray = array(
   2 => array(3 => 'Hello');

function test($arg) {



Then $arg will be a string Hello. It doesn't know or care about where it came from.

Need Your Help

reverse implementation Seq


In the class SeqLike.scala there is a function called reverse which reverses a sequence. For example it makes List(1,2,3,4) to `List(4,3,2,1)

glob function in python with one wildcard

python glob

I have a problem with the glob.glob function in Python.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.