By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,719 Members | 1,220 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,719 IT Pros & Developers. It's quick & easy.

How to reference an array in multidimensional array?

P: n/a
How do I reference an array within an array?

$mapped_array = array_map(null, $data_array, $counter_array);

// okay, so now I have an array of 2 arrays - but how do I reference each
array?
// the next two lines fail to give an accurate count
echo "Starting with ".count($mapped_array[0])." elements in
data_array<br>";
echo "Starting with ".count($mapped_array[1])." elements in
counter_array<br><br>";

// now I want to start at the bottom and look for an IP in each line of
data_array
// which I assume is mapped_array[0]
for ( $i=count($mapped_array[0]); $i > 0; $i-- )
{
$data_line = $mapped_array[0][$i];
$data = explode("|", $data_line);
if( in_array($ip, $data) )
{
// if there's a match, element[$i] of both arrays needs to be spliced
out
array_splice($mapped_array,$i,1);
}
}
// again, these next two lines fail to return an accurate count
echo "Ending with ".count($mapped_array[0])." elements in data_array<br>";
echo "Ending with ".count($mapped_array[1])." elements in
counter_array<br><br>";

Is there something about array_map that prevents me from referencing the
arrays within the array?

Thanks in advance!
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.