Re: Re: setting the same value to multiple variables

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: Re: setting the same value to multiple variables
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-232997@lists.php.net to get a copy of this message
Anthony Ettinger wrote:
($a, $b) = $c; ^^ I don't get the meaning of this...
On 3/31/06, Eduardo Raúl Galván Sánchez <ergalvan@bitam.com> wrote:
You could use variable variables with an array, like this: $arr = array('readingGoalsEnjoymentLabelClass','readingGoalsInformationLabelClass',
     'readingGoalsAlphabeticLabelClass','readingGoalsPrintLabelClass',
     'readingGoalsPhonologicalLabelClass','readingGoalsPhoneticLabelClass',
'readingGoalsComprehensionLabelClass','readingGoalsVocabularyLabelClass',
     'readingGoalsInstructionsLabelClass','readingGoalsCriticalLabelClass',
     'readingGoalsCommunicateLabelClass');
foreach ($arr as $var) {
     ${$var} = 'class="errorHere"';
} /* This is to check if it was done correctly. */ foreach ($arr as $var) {
     echo "$var = ${$var}\n";
} charles stuart escribió:
Hi, I'm sure this is quite basic. Nonetheless I'm new to PHP so I haven't figured it out. I'd like to set each variable to the same value (without having to set that value individually for each variable). Thanks for the help. best, Charles if ( 1 == 1 ) {
    $goodToGo = 0; $errorArray[] = "You must declare some goals on
Activity 1."; // this block of code does not set each variable to "class=\"errorHere\"";
    $readingGoalsEnjoymentLabelClass &&
    $readingGoalsInformationLabelClass &&
    $readingGoalsAlphabeticLabelClass &&
    $readingGoalsPrintLabelClass &&
    $readingGoalsPhonologicalLabelClass &&
    $readingGoalsPhoneticLabelClass &&
    $readingGoalsComprehensionLabelClass &&
    $readingGoalsVocabularyLabelClass &&
    $readingGoalsInstructionsLabelClass &&
    $readingGoalsCriticalLabelClass &&
    $readingGoalsCommunicateLabelClass = "class=\"errorHere\"";
}
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Anthony Ettinger Signature: http://chovy.dyndns.org/hcard.html


« previous php.general (#232997) next »