ballhogjoni Posted January 16, 2008 Share Posted January 16, 2008 How can I seperate an array's value of a specific delimiter? Example= Array ( [0] => 3|1|6|(TESTMODE) The credit card number is invalid.|000000|P|0||Recycled Toner Cartridges|12.23|CC|auth_capture||Charles D.|Gaulle||342 N. Main Street #150|Ft. Worth|TX|12345||||||||||||||||||89BF5BBF7A16901116EE7B99DF55909A|||||||||||||||||||||||||||||||FALSE|Customer Birth Month: 12|Customer Birth Day: 1|Customer Birth Year: 1959|Promotion: Spring Sale ) You see this array has one index and a value (long string) assigned to that index. I would like to seperate that value at each | and make it a new index with the next value. An example would be: Array ([0] => 3, [1] => 1, [2] => 6, [3] => "(TESTMODE) The credit card number is invalid.", etc...) Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted January 16, 2008 Share Posted January 16, 2008 explode("|", $array); Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted January 16, 2008 Author Share Posted January 16, 2008 That outputs: Array ( [0] => Array ) Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted January 16, 2008 Share Posted January 16, 2008 explode('|',$array[0]) Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted January 16, 2008 Share Posted January 16, 2008 More of an example: <?php $new_array = array(); foreach ($old_array as $key => $val) $new_array[$key] = explode('|',$val); echo '<pre>' . print_r($new_array,true) . '</pre>'; // debug ?> Ken Quote Link to comment Share on other sites More sharing options...
ballhogjoni Posted January 16, 2008 Author Share Posted January 16, 2008 Thanks Ken and every one, Kens code did it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.