Not sure if you want to keep the commas in your array, i.e. $array[$0] = 1,

But, if you don't, you can do this;

$string = "1, 2, 3, 4, 5";
@array = split /,/ , $string;
print "@array\n";

If you want to keep the commas, simply replace /,/ with /\s/

Regards,

Danny
-----Original Message-----
From: Kurt Asdal [mailto:[EMAIL PROTECTED]]
Sent: Sunday, December 15, 2002 6:11 PM
To: [EMAIL PROTECTED]
Subject: String to Array


Hello all,
 
  If I have a string, such as:

   $string="1, 6, 8, 10, 15";

 How could I convert it to an array, such as:

   @array(1, 6, 8, 10, 15);


Thanks.....

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to