AW: [PHP] print the name of a variable
| From: | Jens Wabnitz | Date: | Tue, 15 Aug 2000 10:31:00 +0000 |
| Subject: | AW: [PHP] print the name of a variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11771@lists.php.net to get a copy of this message | ||
Hi Bas,
what do you mean with "NAME_OF_VARIABLE"
You write the values of the variables "name, contact, function, adress" in
an array. So you have
fields[0] = value-of name
fields[1] = value-of contact
fields[2] = value-of function
fields[3] = value-of adress
You could do something like
fields["name"] = $name
fields["contact"] = $contact
..
And read out by..
while (list($name, $value) = each($fields))
print "$name ==> $value <BR>";
You want to have the name of a variable, right ?
Ok, how do you want to tell your script which variable you mean ; )
Hope that helps.
Bye
Jens
-----Ursprungliche Nachricht-----
Von: Bas Jochems [mailto:bas@webdisplay.nl]
Gesendet: Dienstag, 15. August 2000 11:32
An: php-general@lists.php.net
Betreff: [PHP] print the name of a variable
Hello all,
How can i print the name of a variable? I mean, when you have $name i
want to add "name" to $body.
Here's an example.
$new_line = "\n<br>";
$fields = array($name, $contact, $function, $adress);
$n = count($fields);
for ($i = 0; $i < $n; $i++) {
if ($fields[$i]) {
// this is were i want to add the name of the variable to $body
$body = $body."NAME_OF_VARIABLE";
$body = $body.$fields[$i];
$body = $body.$new_line;
}
}
anyone knows how to solve this problem?
thanks
Bas
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net