You mean by structure, for example, an array of a model, for example:
array ( 'index' => int, 'tags' => array() )
If this is what you are trying to get, try this ...
$arr1 = array ( array ( 'index' => 0, 'tags' => ['abc'] ), array ( 'index' => 1, 'tags' => ['xyz'] ), array ( 'index' => 2, 'tags' => ['xyz'], 'boom' => 'granade' ), array ( 'index' => 3, 'tags' => 'xyz' ) ); $holder = array(); $model = array ('index' => 0, 'tags' => array()); for ($i = 0;$i < count($arr1); $i++) { $holder = array_diff(array_merge_recursive($arr1[$i], $model), $model); if (!empty($holder)) { echo "different structure<br>"; } else { echo "same structure<br>";
Output Example:
same structure same structure different structure different structure
0yeoj source share