Current location: Hot Scripts Forums » Programming Languages » PHP » storing multiple values in one variable


storing multiple values in one variable

Reply
  #1 (permalink)  
Old 09-25-06, 03:05 PM
Godwin Godwin is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Question storing multiple values in one variable

See code below:
PHP Code:

do {

echo 
$row_Recordset1['mobile'];
echo 
','
} while (
$row_Recordset1 mysql_fetch_assoc($Recordset1)); 
This for an example would produce the follwong result:

077323232,077845848,935683856,

I want to store the entire result as a string in $to variable without the last " , "

The reason I want to store all mobile numbers in a variable is because I'm using a SMS script that should receive mobile numbers in comma seperated format in order to send in bulk.
Ex.
$to = 077323232,077845848,935683856;

First problem is getting rid of the last comma in the result and the second problem is storing the entire result in $to variable.

Please help me.
Reply With Quote
  #2 (permalink)  
Old 09-25-06, 03:59 PM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
Try this.

PHP Code:

$to = array();

do {
$to[] = $row_Recordset1['mobile'];
} while (
$row_Recordset1 mysql_fetch_assoc($Recordset1));  

$to implode(','$to);

echo 
$to
Reply With Quote
  #3 (permalink)  
Old 09-25-06, 04:10 PM
Godwin Godwin is offline
Newbie Coder
 
Join Date: Sep 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Awesome!
That works!

Thank you so much nico_swd
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with Auto Dealer Script nuzzle PHP 17 04-14-10 08:34 PM
using variable variables with multiple variables for parts of the name harlock PHP 7 07-26-05 07:35 PM
Insert multiple values into one field jaydwire2 JavaScript 1 11-02-04 09:47 AM
Putting multiple values from list into one field rush989 PHP 1 02-04-04 04:47 AM


All times are GMT -5. The time now is 05:40 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.