You are here: Re: Setting a varialble using a variable « PHP Programming Language « IT news, forums, messages
Re: Setting a varialble using a variable

Posted by Rik Wasmus on 11/27/07 21:25

On Tue, 27 Nov 2007 21:40:24 +0100, jj <jjwalker71@gmail.com> wrote:

> Trying to understand the manual regarding variables to solve the
> following.
>
> I'm working with Drupal CMS and have a loop to retrieve values that
> are normally fetched by using this variable: $node-
>> field_screen_1_caption[0]['view']. The loop should run n times,
> incrementing that number 1 so next variable is $node-
>> field_screen_2_caption[0]['view'].
>
> Here's what I'm trying in my loop to change that number in the
> variable using $i:
>
> for ($i =3D 1; $i <=3D $number_of_screens; $i++) {
> $cap =3D 'node->field_screen_'.$i.'_caption[0][\'view\']';
> print $$cap;
> }
>
> Doesn't work obviously. Any suggestions for a PHP amateur.

echo $node->{'field_screen_'.$i.'_caption'}[0]['view']

It has some serious flaws in design if you have to use it like that thou=
gh.
-- =

Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация