I require to refer to a Variable through the use of a variable is this possible?

Thankyou

Regards, X

Recommended Answers

All 4 Replies

Example:

echo "$person" . $number . "male";

Would this statement refer to the variable, $person1male?

No. $x="person".$number."male";
echo $$x will print the value stored in $person1male. (considering $number has the value 1 in it!)

commented: Once again helped me with another php problem, thanks ;) +1

i would use ${"person".$number."male"}

Thanks nav worked a charm always on the money you are ;)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.