Is_array does not work. I just want to remove the repeated sizes fields, write the array, and then output the data. However, when writing the array, IS_ARRAY does not seem to work, the results are still written into the table or there are no other better methods to remove the repetition of this field. this is the table & lt ;? Php $ sizes & nbsp; mysql_query (SELECT & nbsp; sizes & nbsp; FROM & nbsp; produ is_array does not work
I just want to remove the repeated sizes fields, write the array, and then output,
However, when writing an array, I used IS_ARRAY to judge whether it worked, and the results were written into the array.
Or there is no better way to remove this field duplication.
This is a table
$ Sizes = mysql_query ("SELECT sizes FROM product ");
$ _ Sizearry = array ();
While (!! $ _ Sizes = mysql_fetch_array ($ sizes )){
If (! Is_array ($ _ sizes ['sizes'], $ _ sizearry )){
$ _ Sizearry [] =_ _ sizes ['size'];
}
}
Print_r ($ _ sizearry );
Foreach ($ _ sizearry as $ size ){
Echo $ size ;}?>
------ Solution --------------------
Is_array () is not used to determine whether duplicate data exists.
Select distinct
------ Solution --------------------
How is is_array? Check whether it is an array?
If (! In_array ($ _ sizes ['sizes'], $ _ sizearry )){
------ Solution --------------------
Whether is_array () is an array type
In_array () determines whether the array has this key value.
while (!!$_sizes = mysql_fetch_array($sizes)){
if (!in_array($_sizes['sizes'],$_sizearry)) {
$_sizearry[] = $_sizes['sizes'];