About query issues

Source: Internet
Author: User
Say
$array _a={1,1,1,2,2,2,3,3,3,4,4,4,5,5,5}
$array _b={a,a,a,a,a,b,b,b,b,c,c,c,s,s,s}
$array _c={b,b,c,d,d,s,a,s,d,s,a,d,a,d,d}

Think of it as a database, 3 fields and content.

I want to use the PHP array function to implement the database where query for example is where $array _a=1 content is AAA and BBC
How do I write in PHP? I can't use this method because the environment has too many limits.


Reply to discussion (solution)

This is not the right description, if equal to 2, the time equals 3 o'clock?

Did not think of any good way, can only according to the value of a to check the respective position of the corresponding elements, and then use these locations to B,c to take the value

Why not:
$ABC = Array (Array (1, ' A ', ' B '), Array (1, ' A ', ' B '),)
or save it as a file emulation database. Then customize the search function

$array _a = Explode (', ', ' 1,1,1,2,2,2,3,3,3,4,4,4,5,5,5 '); $array _b = Explode (', ', ' a,a,a,a,a,b,b,b,b,c,c,c,s,s,s '); $ Array_c = Explode (', ', ' b,b,c,d,d,s,a,s,d,s,a,d,a,d,d '); $res _a = Array_keys ($array _a, 1); $res _b = Array_intersect_key ( $array _b, Array_flip ($res _a)), $res _c = Array_intersect_key ($array _c, Array_flip ($res _a));p Rint_r ($res _b);p Rint_r ($ Res_c);
Array
(
[0] = a
[1] = a
[2] = a
)
Array
(
[0] = b
[1] = b
[2] = C
)

$array _a = Explode (', ', ' 1,1,1,2,2,2,3,3,3,4,4,4,5,5,5 '); $array _b = Explode (', ', ' a,a,a,a,a,b,b,b,b,c,c,c,s,s,s '); $ Array_c = Explode (', ', ' b,b,c,d,d,s,a,s,d,s,a,d,a,d,d '); $res _a = Array_keys ($array _a, 1); $res _b = Array_intersect_key ( $array _b, Array_flip ($res _a)), $res _c = Array_intersect_key ($array _c, Array_flip ($res _a));p Rint_r ($res _b);p Rint_r ($ Res_c);
Array
(
[0] = a
[1] = a
[2] = a
)
Array
(
[0] = b
[1] = b
[2] = C
)
Using Array_intersect_key to search for good Array_flip ($res _a) is this feeling superfluous?
  • 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.