How to get data from multidimensional array by ommiting one column?

I am storing info in an array in a loop like that:

while ($ind = mysql_fetch_array($result))
    $array["uniqueName"][$ind][$hash]["mac"] = $mac;

How can I get all $mac's if I am not given $hash, so by all hashes in context:

$array["uniqueName"][432][?]["mac"]

What can I do with '?' above? Can I ommit that somehow?

Thank you.

Answers


you can loop over the hash keys like this:

$macs = array();
foreach($array["uniqueName"][$ind] as $hash){
    array_push($macs, $hash["mac"]);
}

Update from comment:

The foreach statement loads every key $array["uniqueName"][$id] contains into the $hash variable, one by one. So you don't have to know what these keys actually are (or even if there are any), you can just use them by referring to them using the $hash var. So in effect, that foreach statement loops over all keys $array["uniqueName"][$id] contains.


Need Your Help

Accessing Controls Inside ASP.NET View Controls (Event Handling)

asp.net vb.net events listview dynamic

If I have the following ListView, how can I attach a SelectedIndexChanged event listener to the DropDownList so I can perform a command on the respective object? Imagine I have a list of new users ...

Trivial texture load in andengine

android load textures andengine

In andngine , I defined a texture, using the following line code:

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.