Jump to content

size of 2d array


thiggins09

Recommended Posts

try

<?php

function size_of_arr($a){
$b = 0;
if (is_array($a)) {
	foreach ($a as $c) $b += size_of_arr($c);
	return $b;
}
return 1;
}

$a = array(1,array(2,3),4,array(5,array(6,7,,9),10);
echo '<pre>';
print_r($a);
echo "</pre><hr />\n";
echo 'Size is: ', size_of_arr($a);
?>

Link to comment
https://forums.phpfreaks.com/topic/50843-size-of-2d-array/#findComment-250102
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.