php - split array values into two arrays -


i trying figure out how split values inside array. have looked code put me on right path, have had no luck. ideally take following input , split 2 separate arrays. each pair listed below ie: (12,13) 1 array value.

12,13
12,14
12,15
12,16
12,17
12,18
12,21
12,22

any assistance can give muchly appreciated!

assuming you're having 1 array values above, eg:

$foo = array("12,13", "12,14", "12,15", ...); $outa = array(); $outb = array(); foreach($foo $value) {     list($x, $y) = explode(",",$value);     $outa[] = $x;     $outb[] = $y; } print_r($outa); print_r($outb); 

you'd want error checking in there somewhere though.

if don't (yet) have numbers in array in text file use phps file function them there.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -