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 7 people (86%) answered Yes
Recently 6 of 7 people (86%) answered Yes


How do u explode a string of content and then call each individual bit by it's own, new, variable???

Feb 24th, 2008 19:41
dman, Brian Broadhead, jarrod nettles, http://www.ttnr.org

explode("seperator", $some_string);
Your original string must have a seperator.
Notice the seperator below is the colon (:)
This example saved 6 columns (fields) in a database.
Yes! The thought of a 1 column database did tempt me!!
$color_scheme = "1:008800:ffffff:000000:db7093:ffffff:bbddc6";
          $split_color = explode(":", $color_scheme);
          $button      = $split_color[0];
          $text1       = $split_color[1];
          $text2       = $split_color[2];
          $text3       = $split_color[3];
          $table1      = $split_color[4];
          $table2      = $split_color[5];
          $bkground    = $split_color[6];
Use eg.  '$button' or '$split_color[0]' whatever suits you