0

I have 4 arrays for input errors like:

$username_errors=array();
$email_errors=array();
$password_errors=array();
$errors=array();

I want to merge all the arrays values in $errors array and count if $errors is empty then proceed. Thanks in advance.

gturri
  • 13,807
  • 9
  • 40
  • 57
user3260392
  • 151
  • 1
  • 11
  • 2
    Well you could show us what you tried before anything. Anyway, you should look at `array_merge` function http://www.php.net/manual/en/function.array-merge.php – Justin Iurman Feb 01 '14 at 12:47
  • you could use the `array_push()`. like `array_push($errors,$username_errors);` – rockStar Feb 01 '14 at 12:48
  • possible duplicate of [Merging multiple array then sorting by array value count](http://stackoverflow.com/questions/2736635/merging-multiple-array-then-sorting-by-array-value-count) – Oerd Feb 01 '14 at 12:55

2 Answers2

1

use array_merge

$arr = array_merge($arr1, $arr2, $arr3);
Sabuj Hassan
  • 38,281
  • 14
  • 75
  • 85
0
$array3 = array_merge($array1, $array2);
Unix von Bash
  • 735
  • 5
  • 20