Forum Moderators: coopster

Message Too Old, No Replies

Breaking the continuous array

         

kkonline

1:56 pm on Mar 16, 2008 (gmt 0)

10+ Year Member



I have the following array,

[php]Array ( [0] => 16+37+24 [2] => 16+37+24 [4] => 16+37+24 )[/php]

Where '+' is the delimiter and Section+Category+Page format.

Now i want to separate each value in the array... for example 16+37+24 to get the output
Section value as 16 , Category value as 37 and Page value as 24.

For removing the delimiter and processing to get the desired result what can I do?

PHP_Chimp

3:17 pm on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a look at explode [php.net] as you can split each element in the array with that.

Something like -


$new_array = array();
foreach($array as $k => $v) {
$new_array[$k].= explode('+', $v);
}

You will need to test that, as I havent. But should get you in the right direction ;)

kkonline

3:44 pm on Mar 16, 2008 (gmt 0)

10+ Year Member



finally for each set i want the section in $section variable and category in $category variable and page in $page .. so that i can return back ($category,$section,$page) back to the calling function to show the content. what to do for it?

cameraman

6:24 pm on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Have a look at list [us2.php.net] combined with php_chimp's code above.