variable in random array?

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

Post Reply
jasondavis
Forum Commoner
Posts: 60
Joined: Sat Feb 04, 2006 5:35 pm

variable in random array?

Post by jasondavis »

Code: Select all

$random_array = array('w4w $friend_count  friends here', 'click me', 'I can get you tons of friends...I have over $friend_countk');
How can I get the variables friend_count to work in the array like that, I dont have proper synthax
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Replace the ' (single quote) with " (double quote) :wink:
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

...or like this

Code: Select all

$random_array = array('w4w '.$friend_count.'  friends here', 'click me', 'I can get you tons of friends...I have over '.$friend_countk.'');
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

Yes, both are fine 8)
Post Reply