Array alignment Problems

Source: Internet
Author: User
Implementing string ' Off-road, City Sub ' (length=16)
Compared to the array of ' wjc_title ' and string ' 2 saloon Cars ' (length=13), see if there are conditions to meet,

What's up, just learning PHP soon


Reply to discussion (solution)

Do not map, paste out your array.
What do you mean by satisfying the conditions?

Do not map, paste out your array.
What do you mean by satisfying the conditions?


String ' Off-road, City sub ' compared to Wjc_title in array $list, see if there are any in the array? The array is printed out as

Does the traversal of each value in your first array exist in the second one?

Put out your text array, or else people will have to spend time structuring your array.

Does the traversal of each value in your first array exist in the second one?

Put out your text array, or else people will have to spend time structuring your array.


The first is the multi-select value that the Ajax passes over, and the second $list is the query data.

I'm not going to ask you how two arrays are getting, it's about asking what you want to output and what you want to get.

I'm not going to ask you how two arrays are getting, it's about asking what you want to output and what you want to get.


Okay, moderator hard ... Match, if there is one or two matches. True anti-sub false

It's so hard for you to put your array on, and that makes my saliva dry.

$ar 1 = Array (' A1 ', ' A2 '); $ar 2 = Array (' wjc_id ' = ' + '  , ' wjc_title ' = ' A1 '),  array (' wjc_id ' = ') ' Wjc_title ' = ' sfdsds '), function foo ($value) {     global $ar 2; $num = 0; foreach ($ar 2 as $v) {      if ($value = = $ v[' Wjc_title ') $num + +; } return $num > 0;} foreach ($ar 1 as $v) {    echo $v. ------"; Var_dump (foo ($v)). Php_eol;}
A1------BOOL (TRUE)
A2------bool (FALSE)

foreach ($list as $keys = + $values) {        if (In_array ($values [' Wjc_title '], $b)) {                echo ' continues ';        } else {                echo ' end ';        }}

This kind of writing seems to have a problem, is not $b (the first) to be converted to $list (the second array) to compare, in addition to this write every time the loop will enter the results, I want to compare the completion of the output compared to the results of the line

The first is the multi-select value that the Ajax passes over, and the second $list is the query data.


So, just check the database.

It's so hard for you to put your array on, and that makes my saliva dry.

$ar 1 = Array (' A1 ', ' A2 '); $ar 2 = Array (' wjc_id ' = ' + '  , ' wjc_title ' = ' A1 '),  array (' wjc_id ' = ') ' Wjc_title ' = ' sfdsds '), function foo ($value) {     global $ar 2; $num = 0; foreach ($ar 2 as $v) {      if ($value = = $ v[' Wjc_title ') $num + +; } return $num > 0;} foreach ($ar 1 as $v) {    echo $v. ------"; Var_dump (foo ($v)). Php_eol;}
A1------BOOL (TRUE)
A2------bool (FALSE)


Var_dump (foo ($v)). Php_eol; output always False

$ar 1 = Array (' A1 ', ' A2 '); $ar 2 = Array (' wjc_id ' = ' + '  , ' wjc_title ' = ' A1 '),  array (' wjc_id ' = ') ", ' wjc_title ' = ' Sfdsds '); function foo ($item) {  global $value;  return $value = = $item [' Wjc_title '];} foreach ($ar 1 as $value) {  echo $value, ', Array_filter ($ar 2, ' foo ')? ' In ': ' Not ', php_eol;}
A1 in
A2 not here.
  • 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.