Current location: Hot Scripts Forums » Programming Languages » PHP » String to array...HOW?


String to array...HOW?

Reply
  #1 (permalink)  
Old 03-16-09, 06:14 AM
tomming tomming is offline
Newbie Coder
 
Join Date: Jan 2009
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
String to array...HOW?

Php problem again!
I get a string "1,2,3,4"
I want to insert it to an array ,that mean:
$string = "1,2,3,4";
$variable = array($string);
HOW
Reply With Quote
  #2 (permalink)  
Old 03-16-09, 06:32 AM
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
Quote:
Originally Posted by tomming View Post
I want to insert it to an array
Quote:
$string = "1,2,3,4";
$variable = array($string);
... you've just answered your own question? You're really not explaining well what you're trying to accomplish. But my guess is you actually want each number to be an element of the array? If so, do it this way:
PHP Code:

$numbers explode(','$string); 

www.php.net/explode
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
OOP C-Sharp DB Access Wrapper Question digioz ASP.NET 1 09-08-08 09:54 AM
search function using dot net nishudude_13 Windows .NET Programming 1 08-28-08 11:28 AM
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' Dr. Forensics PHP 3 07-15-06 03:54 PM
Declared Functions skipper23 PHP 4 12-17-03 10:06 AM
index page not showing up skipper23 PHP 3 12-15-03 01:10 PM


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