faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 11 people (55%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How and you split string into different arrays and save what they were split on?

Feb 26th, 2008 00:02
dman, Jeroen Keppens, Cinley Rodick, brendan conroy, http://www.ttnr.org


<?
// First method
   $fruit = "apple,orange,pear";
   $fruit_array = explode(",", $fruit);
   // values in $fruit_array
   // $fruit_array[0] = "apple"
   //         ... [1] = "orange"
   //         ... [2] = "pear"
// Second method
   $fruit = "apple,orange,pear";
   $fruit_array = split(",", $fruit);
   // values in $fruit_array
   // $fruit_array[0] = "apple"
   //         ... [1] = "orange"
   //         ... [2] = "pear"
   // Split can use regular expressions in the pattern
?>
hope this answers your question!
Jeroen