Php determines whether it is an array program code. In php, it is very easy to determine whether the variable is an array. Using the is_array () function in php can quickly determine whether the variable is an array. I will introduce it to you below. Is_array: it is very easy to check whether the variable is an array in php. Using the is_array () function in php, you can quickly determine whether the variable is an array. I will introduce it to you below.
Is_array-check whether the variable is an array
Report a bug description
Bool is_array (mixed $ var)
If var is array, TRUE is returned; otherwise, FALSE is returned.
Example
| The code is as follows: |
|
|
$ A = 1;
If (is_array ($ ))
{
Echo 'is an array ';
}
Else
{
Echo 'not array 0 ';
} |
Example
| The code is as follows: |
|
|
Function is_vector (& $ array ){
If (! Is_array ($ array) | empty ($ array )){
Return-1;
}
$ Next = 0;
Foreach ($ array as $ k => $ v ){
If ($ k! ==$ Next) return false;
$ Next ++;
}
Return true;
}
?> |
Method for determining whether to index an array
Echo is_assoc ($ array )? 'Index array': 'not an index array ';
| The code is as follows: |
|
|
Function is_assoc ($ array ){
If (is_array ($ array )){
$ Keys = array_keys ($ array );
Return $ keys! = Array_keys ($ keys );
}
Return false;
} |
The evaluate () function can quickly determine whether the variable is an array. I will introduce it to you below. Is_array checks whether the variable is a number...