Is_array does not work. how can this problem be solved?

Source: Internet
Author: User
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'];

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.