php - exploding textarea values into multiple array -
exploding textarea value this:
explode("\n", $input);
would result in 1 array.
currently, storing $input in textarea this:
a1 a2 a3 b1 b2 b3 c1 c2 c3
but want multiple array result this:
$test[0][0] = 'a1'; $test[0][1] = 'a2'; $test[0][2] = 'a3'; $test[1][0] = 'b1'; $test[1][1] = 'b2'; $test[1][2] = 'b3'; $test[2][0] = 'c1'; $test[2][1] = 'c2'; $test[2][2] = 'c3';
any idea, how can implement?
explode two newlines separate groups, explode each group single newline:
$result = array_map( function ($group) { return explode("\n", $group); }, explode("\n\n", $input) );
Comments
Post a Comment