0

I need to assign the same value to different variables, but cannot do it like this because some of the are like this $var_a .= blah'

$var_a = $var_b = $same_var = $var_d = $some_var = 'A';

Is there another way to assign the same value to multiple variables?

Something like $var_a .=, $var_b .= 'this value'

1
  • AFAIK, nope there's no such way. Commented Jun 29, 2013 at 10:27

1 Answer 1

2

In a single line? No, as far as I know, but this would be a horrible style in my opinion.

Use this:

$var_a .= 'this value';
$var_b .= 'this value';

If you really want a one-liner, try this:

list($a, $b) = array_map(function($i) {return $i . 'EXT';}, array($a, $b));
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.