PHP two-dimensional array of problems, ask the big God solution

Source: Internet
Author: User
I have a page now. searchfangxiang.php defines a two-dimensional array:
Array ("FID" = "101", "Name" = "Automation Institute", "Professor" and "Professor Zhang"),
' fid102 ' =>array ("fid" = "102", "Name" = "Lab", "Professor" and "Professor Li"),
' fid103 ' =>array ("fid" = "103", "Name" and "Science Institute", "Professor" and "Professor Wang"););

?>

The page of this two-dimensional array is then referenced in my application page


echo " ";
?>

Now the App page has an ID how do I traverse this two-dimensional array, find the same set of FID in the two-dimensional array as the page ID, and then Label to output this group of information


Reply to discussion (solution)

The way you organize your data, you don't need to traverse
Just echo $fangxiang ["fid$id"] [' Name ']; Can

Go to JSON and put it on the app page, read with JS or jquery

The way you organize your data, you don't need to traverse
Just echo $fangxiang ["fid$id"] [' Name ']; Can


Yes, I think it's complicated.


The way you organize your data, you don't need to traverse
Just echo $fangxiang ["fid$id"] [' Name ']; Can



I'm too novice, I'm still in the loop.

If it's not organized like this,

$fangxiang = Array (  ' fid101 ' = = Array ("FID" = "101", "Name" = "Automation Institute", "Professor" and "Professor Zhang"),  ' fid102 ' = = Array ("FID" = "102", "Name" = "Lab", "Professor" and "Professor Li"),  ' fid103 ' = = Array ("FID" = " 103 "," Name "=" Science Institute "," Professor "and" Professor Wang ");
But it's organized like this.
$fangxiang = Array (0 = = Array (  "fid" = "101", "Name" = "Automation Institute", "Professor" and "Professor Zhang"),  1 = = Array ( "FID" and "102", "name" and "Lab", "Professor" and "Professor Li",  2 = = Array ("FID" = "103", "name" = "Science Institute", " Professor "" and "Professor Wang");
Then we need to traverse the
foreach ($fangxiang as $item) {  
See the right data structure for a multiplier effect

If it's not organized like this,

$fangxiang = Array (  ' fid101 ' = = Array ("FID" = "101", "Name" = "Automation Institute", "Professor" and "Professor Zhang"),  ' fid102 ' = = Array ("FID" = "102", "Name" = "Lab", "Professor" and "Professor Li"),  ' fid103 ' = = Array ("FID" = " 103 "," Name "=" Science Institute "," Professor "and" Professor Wang ");
But it's organized like this.
$fangxiang = Array (0 = = Array (  "fid" = "101", "Name" = "Automation Institute", "Professor" and "Professor Zhang"),  1 = = Array ( "FID" and "102", "name" and "Lab", "Professor" and "Professor Li",  2 = = Array ("FID" = "103", "name" = "Science Institute", " Professor "" and "Professor Wang");
Then we need to traverse the
foreach ($fangxiang as $item) {  
See the right data structure for a multiplier effect



Great God I have another question, I now want to do a search on the page function, how to write Fuzzy lookup Ah, such as I search "science", put the name of science two words
This group of information to find out, the search name is the same, PHP can do this

This effect should be done with JS

 
   Array ("FID" = "101", "name" = "Automation Institute", "Professor" and "Professor Zhang"),                 ' fid102 ' =>array ("fid" = "102", "name "=" Lab "," Professor "and" Professor Li "),                 ' fid103 ' =>array (" fid "=" 103 "," Name "=" Science Institute "," Professor " "Professor Wang")); $id = 101;? >
 
   
 
    ". $fangxiang [' FID '. $id] [" Name "].";? >

Search for.

 
   Array ("FID" = "101", "name" = "Automation Institute", "Professor" and "Professor Zhang"),  ' fid102 ' = = Array ("FID" = "102", "name "+" laboratory "," Professor "and" Professor Li "),  ' fid103 ' = = Array (" FID "=" 103 "," Name "=" Science Institute "," Professor "= "Professor Wang"); >
 
   

Search Key:

Type Name Professor

  • Related Article

    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.