Is_array judgment does not work, how to solve

Source: Internet
Author: User
Is_array judgment doesn't work.
I just want to remove the repetition of the sizes field, write the array, and then output,
But when I write to the array, it doesn't seem to work with Is_array, and the results are all written in.
Or is there any better way to get rid of the repetition of this field?
This is the table.


$sizes = mysql_query ("Select sizes from Product");

$_sizearry = Array ();
while (!! $_sizes = mysql_fetch_array ($sizes)) {
if (!is_array ($_sizes[' sizes '],$_sizearry)) {
$_sizearry[] = $_sizes[' sizes '];
}
}
Print_r ($_sizearry);
foreach ($_sizearry as $size) {
echo $size;}? >


------Solution--------------------
Is_array () is not used to determine if there is duplicate data
SELECT DISTINCT
------Solution--------------------
Why is it Is_array? Check if it is an array?
if (! In_array($_sizes[' sizes '],$_sizearry)) {
------Solution--------------------
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.