Re: Question about 'sizeof'
On May 8, 11:50 am, SM <servandomont...@gmail.com> wrote:
> On May 8, 11:42 am, Piotr <s...@poczta.onet.pl> wrote:
>
>
>
> > >> $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?
>
> > > You should use variable variable:
> > > $item_total = sizeof($$item);
>
> > > Mark double $$
> > > This is true in any situation, not only with sizeof
>
> > Forgot about one small detail:
> > $item = 'thumbs_cat_' . $thumb; //this outputs a string:
> > ---------^ loose the '$';
>
> > best regards
> > Piotr N
>
> I don't need the length of the string , just the actual variable. But
> i did like the fact that sizeof is an alias of count. So i will use
> count instead.
> I didn't know about the $$ tip. Wow! so easy. Thanks, It Works!
>
> Heres the final code:
>
> $thumb = 1;
> $item = 'thumbs_cat_' . $thumb;
> $item_total = count($$item);
>
> Thanks again
> Marco
Maybe i should open a new post for this one, but here it goes:
I'm stock! When i want to reference that variable in a echo statment,
it does't work. Any suggestions?
Thanks
<li><a href="<?php echo $SERVER['PHP_SELF']; ?>?cat=<?php echo
$category_this; ?>"><img src="images/<?php echo($$item[$i]);?>"
alt="" /></a></li>
|