Advertisement
Guest User

Untitled

a guest
Jul 24th, 2014
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. function array_2d_to_1d ($input_array) {
  2. $output_array = array();
  3.  
  4. for ($i = 0; $i < count($input_array); $i++) {
  5. for ($j = 0; $j < count($input_array[$i]); $j++) {
  6. $output_array[] = $input_array[$i][$j];
  7. }
  8. }
  9.  
  10. return $output_array;
  11. }
  12.  
  13. $array = array(array('green', 'yellow', 'orange'), array('blue', 'black', 'white'));
  14. $newarray = array();
  15. foreach (array_values($array) as $value){
  16. $newarray[] = $value;
  17. }
  18.  
  19. function array_to1d($a) {
  20. $out = array();
  21. foreach ($a as $b) {
  22. foreach ($b as $c) {
  23. if (isset($c)) {
  24. $out[] = $c;
  25. }
  26. }
  27. }
  28. return $out;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement