470,848 Members | 1,694 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

mult variable assignmesnt on one line

In Python, I can do something like this:

a,b,c = 1,2,3

How might I do this with PHP?

Thanks,
Bart

Jul 17 '05 #1
4 1555
Bart Nessux wrote:
In Python, I can do something like this:

a,b,c = 1,2,3

How might I do this with PHP?

Have a look at list()
http://www.php.net/manual/en/function.list.php

list($a, $b, $c) = Array(1, 2, 3);

should do it. But it's not as readable as Python... !-)

Bruno

Jul 17 '05 #2
Bruno Desthuilliers wrote:
Bart Nessux wrote:
In Python, I can do something like this:

a,b,c = 1,2,3

How might I do this with PHP?

Have a look at list()
http://www.php.net/manual/en/function.list.php

list($a, $b, $c) = Array(1, 2, 3);

should do it. But it's not as readable as Python... !-)

Bruno


Thanks for the tip... guess I'll stick to doing on var at a time. One
last question: How can I split long lines of PHP code up into smaller
lines? For example, how can I turn this line:

$12 = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;

into this line:

$12 = xxxxxxxxxxxxxx
xxxxxxxxxxxxxx
xxxxxxxxxxxxxx;

Thanks,
Bart

Jul 17 '05 #3
Bart Nessux wrote:
Bruno Desthuilliers wrote:
Bart Nessux wrote:
In Python, I can do something like this:

a,b,c = 1,2,3

How might I do this with PHP?
Have a look at list()
http://www.php.net/manual/en/function.list.php

list($a, $b, $c) = Array(1, 2, 3);

should do it. But it's not as readable as Python... !-)

Bruno


Thanks for the tip... guess I'll stick to doing on var at a time.


Yeps, I think that's a better choice here. Still, the list() function
may come in handy sometimes...
One
last question: How can I split long lines of PHP code up into smaller
lines? For example, how can I turn this line:

$12 = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;

into this line:

$12 = xxxxxxxxxxxxxx
xxxxxxxxxxxxxx
xxxxxxxxxxxxxx;

Assuming the xxxx is php code (not a string), you don't have anything
special to do. Like C and most maintstream languages, PHP uses ';' as
the instruction delimiter. So newlines, whitespaces etc have no special
meaning.

HTH
Bruno

Jul 17 '05 #4

"Bruno Desthuilliers" <bd*****************@free.quelquepart.fr> wrote in
message news:40*********************@news.free.fr...
<snip>
One
last question: How can I split long lines of PHP code up into smaller
lines? For example, how can I turn this line:

$12 = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;

into this line:

$12 = xxxxxxxxxxxxxx
xxxxxxxxxxxxxx
xxxxxxxxxxxxxx;

Assuming the xxxx is php code (not a string), you don't have anything
special to do. Like C and most maintstream languages, PHP uses ';' as
the instruction delimiter. So newlines, whitespaces etc have no special
meaning.

HTH
Bruno


In the case that it IS a string, you could do this (using the .
concatenation operator):
$a = "xxxxxxxxxxxxxx".
"xxxxxxxxxxxxxx".
"xxxxxxxxxxxxxx";

Garp
Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

83 posts views Thread by Alexander Zatvornitskiy | last post: by
3 posts views Thread by Bryan Parkoff | last post: by
44 posts views Thread by gokkog | last post: by
1 post views Thread by David W | last post: by
3 posts views Thread by GaryDean | last post: by
reply views Thread by Cameron Simpson | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.