try the following:
$file_data_array = array( 'title'=>array(), 'content'=>array(), 'date_posted'=>array() ); //go through each question foreach($file_data as $value) { //separate the string by pipes and place in variables list($title, $content, $date_posted) = explode('|', $value); //create an associative array for each input $file_data_array['title'][] = $title; $file_data_array['content'][] = $content; $file_data_array['date_posted'][] = $date_posted; }
your last array will look something like this:
$file_data_array = array( 'title' => array ( 't1', 't2' ), 'content' => array ( 'c1', 'c2' ), 'date_posted' => array ( 'dp1', 'dp2' ) )
here is a demonstration of this:
http://codepad.org/jdFabrzE
Neal
source share