View Single Post

  #1 (permalink)  
Old 05-08-2008
SM
 
Posts: n/a
Default Question about 'sizeof'

Hello,
I have another simple question about an array in PHP and a variable in
PHP.

This is the array:

$thumbs_cat_1 = array(
'wine',
'cheese',
'ice',
'bread'
);


$thumbs_cat_2 = array(
'hello',
'goodbye'
);


This will work:
$item_total = sizeof($thumbs_cat_1);
output: 4

$item_total = sizeof($thumbs_cat_2);
output: 2


Now, i want to replace the parameter in 'sizeof' by a variable

$thumb = 1;
$item = '$thumbs_cat_' . $thumb; //this outputs a string:
$thumbs_cat_1

$item_total = sizeof($item);
output: Nothing!

How do i pass a variable to the 'sizeof' function?

Thanks
Marco

Reply With Quote