Re: how to combine the results of two variables to echo another variable?
- From: Sacs <alan_nospam_@xxxxxxxxx>
- Date: Fri, 29 Apr 2005 10:51:43 +1200
Ewoud Dronkert wrote:
Sacs wrote:
Variable variables: http://www.php.net/manual/en/language.variables.variable.php
Yes. But why......:
Variable variables are one of the most powerfull features of php I've found. Very usefull when you dont know how many variables to be processed in a form for e.g.
for( $i=1; $i <= $num_fields; $i++) {
$blah = "field_" . $i;
// $blah is now "field_1" first time through the loop $blah = $$blah;
// now $blah holds what was input into the appropriate input
}echo '<form>
<input type=text name="field_1">
<input type=text name="field_2">
<input type=text name="field_3">
<input type=hidden name="num_fields" value=3>
<input type=submit>
</form>';With just $fooboo = $a . $b; then $fooboo is set to "foobar" not "blah blah" as op wanted.
$fooboo = "$a" . "$b";
Just do: $fooboo = $a . $b;
Sacs .
- Follow-Ups:
- Re: how to combine the results of two variables to echo another variable?
- From: Norman Peelman
- Re: how to combine the results of two variables to echo another variable?
- From: Hannes Dorbath
- Re: how to combine the results of two variables to echo another variable?
- From: Philip Olson
- Re: how to combine the results of two variables to echo another variable?
- From: Ewoud Dronkert
- Re: how to combine the results of two variables to echo another variable?
- References:
- Prev by Date: Re: How long is too long for a cgi script?
- Next by Date: Re: how to combine the results of two variables to echo another variable?
- Previous by thread: Re: how to combine the results of two variables to echo another variable?
- Next by thread: Re: how to combine the results of two variables to echo another variable?
- Index(es):
Relevant Pages
|