View Single Post
Old 09-29-2009, 05:34 AM  
irbobo
Confirmed User
 
irbobo's Avatar
 
Industry Role:
Join Date: Dec 2005
Posts: 410
PHP Code:
<?
$str = "description title:description text;description title2:description text2;";

function data_to_array($str)
{
    foreach( explode(';',$str) as $value )
        if( !empty($value) && strstr($value, ':') )
            $newarray[] =  array( 'title'=>current(explode(':', $value)), 'description'=>end(explode(':', $value)) );
        
    return $newarray;
}

print_r(data_to_array($str));
?>
output is:

Code:
Array
(
    [0] => Array
        (
            [title] => description title
            [description] => description text
        )

    [1] => Array
        (
            [title] => description title2
            [description] => description text2
        )

)
__________________

Last edited by irbobo; 09-29-2009 at 05:36 AM..
irbobo is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote