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
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
Comment