[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general
Subject:    Re: [PHP] Manipulating variables
From:       Jim Lucas <lists () cmsws ! com>
Date:       2011-02-24 5:21:13
Message-ID: 4D65EAC9.7070502 () cmsws ! com
[Download RAW message or body]

On 2/23/2011 8:48 PM, Ron Piggott wrote:
>
> Is there a way to make this syntax:
>
> $checking_answer = $answer_reference_2;
>
> Equal to:
>
> $checking_answer = $answer_reference_ . ($i + 1);
>
> (where $i = 1)
>
> making $checking_answer take on the value of $answer_reference_2 ?
>
> I am trying to develop a web app quiz and I need to test the users answers.
>
> Ron
>
> The Verse of the Day
> "Encouragement from God's Word"
> http://www.TheVerseOfTheDay.info
>

Give this a try
<?php

# Variable Variables Test

$id_0 = 'zero';
$id_1 = 'one';
$id_2 = 'two';
$id_3 = 'three';

for ( $i=0; $i<4; $i++ ) {
     echo ${'id_'.$i};
}

?>

-- 
Jim Lucas
http://www.cmsws.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic