PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
montyauto
Forum Commoner
Posts: 25 Joined: Sat Jan 13, 2007 7:05 am
Post
by montyauto » Sun Feb 25, 2007 2:00 pm
feyd wrote: Standard variables cannot be two, separate words (by spaces.) You need to look at
arrays more or
variable variables .
I have been looking from both array & variable variables
still found no way to get string from variable..
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Sun Feb 25, 2007 2:04 pm
You would set up array keys, and then output the array key as the variable name and $array[$array_key] for the value.
montyauto
Forum Commoner
Posts: 25 Joined: Sat Jan 13, 2007 7:05 am
Post
by montyauto » Sun Feb 25, 2007 2:14 pm
Ambush Commander wrote: You would set up array keys, and then output the array key as the variable name and $array[$array_key] for the value.
I can't get it, still blank idea..
would you pls show me that way with the code?
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Sun Feb 25, 2007 2:17 pm
Code: Select all
$person['name'] = 'John';
$person['favorite color'] = 'gold';
print 'hey friend, ';
foreach ($person as $property => $value) {
print "his $property is $value, ";
}
montyauto
Forum Commoner
Posts: 25 Joined: Sat Jan 13, 2007 7:05 am
Post
by montyauto » Sun Feb 25, 2007 2:33 pm
Ambush Commander wrote: Code: Select all
$person['name'] = 'John';
$person['favorite color'] = 'gold';
print 'hey friend, ';
foreach ($person as $property => $value) {
print "his $property is $value, ";
}
thanks now I get what you mean
but, again, I need to write in the code:
not
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sun Feb 25, 2007 2:38 pm
It's not going to happen. Why do you need this so specifically? What's the actual case you are dealing with?
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Sun Feb 25, 2007 2:50 pm
Try...
Code: Select all
$vars = array('name', 'age');
$something = compact($vars);
$something is now an array you can iterate over.
montyauto
Forum Commoner
Posts: 25 Joined: Sat Jan 13, 2007 7:05 am
Post
by montyauto » Sun Feb 25, 2007 3:56 pm
Finaly I just get the answer.
Last edited by
montyauto on Sun Feb 25, 2007 4:15 pm, edited 1 time in total.
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Sun Feb 25, 2007 4:04 pm
I seriously do not think this is the way you should be going about doing this. You've possibly introduced a security vulnerability and the code won't make much sense to other people.
montyauto
Forum Commoner
Posts: 25 Joined: Sat Jan 13, 2007 7:05 am
Post
by montyauto » Sun Feb 25, 2007 4:17 pm
Ambush Commander wrote: I seriously do not think this is the way you should be going about doing this. You've possibly introduced a security vulnerability and the code won't make much sense to other people.
If it is the case then I should appologize.
I have edited my previous post.
Ambush Commander
DevNet Master
Posts: 3698 Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US
Post
by Ambush Commander » Sun Feb 25, 2007 4:19 pm
There's no need to remove the link, we're just trying to help you.