How to invoke an array in PHP

Source: Internet
Author: User
I enter "Bai" in the search box to automatically prompt "Baidu" and "Baidu image",
Click on the corresponding tag to enter the corresponding website (such as click "Baidu", open http://baidu.com), html+js should be realized, now want to use the way the array of data written in PHP, this How to write Ah, that is, this paragraph
var mockdata=[{name: ' Baidu ', Link: ' http://www.baidu.com '},{name: ' Baidu image ', Link: ' http://image.baidu.com '}]
How to write in PHP and be called

 
  
 <title>How to query an array</title>
 
  
 Please enter what you want to search for
 
 


    Reply to discussion (solution)

    $ar = Array (  ' name ' = ' Baidu ', ' link ' = ' http://www.baidu.com '),  Array (' name ' = ' Baidu ', ' Link ' = ' http://www.baidu.com '),  Array (' name ' = ' Baidu ', ' link ' = ' http://www.baidu.com '), $s = Json_ Encode ($ar); echo "var mockdata = $s;";


    $ar = Array (  ' name ' = ' Baidu ', ' link ' = ' http://www.baidu.com '),  Array (' name ' = ' Baidu ', ' Link ' = ' http://www.baidu.com '),  Array (' name ' = ' Baidu ', ' link ' = ' http://www.baidu.com '), $s = Json_ Encode ($ar); echo "var mockdata = $s;";


    No, No. Cannot invoke
    mockdata.php
     
      ' Baidu ', ' link ' = ' http://www.baidu.com ',  Array (' name ' = ' Baidu ', ' link ' = ' http://www.baidu.com '),  Array (' name ' = ' Baidu ', ' link ' = ' http://www.baidu.com '), $s = Json_encode ($ar); echo "var mockdata = $s;";? >


    Index.html

     
      
     <title>How to query an array</title>
     
      
     Please enter what you want to search for
     
     

      You have enough!
      You are advised to consult your teacher to find out the difference between the SRC attribute and the script tag without the SRC attribute!

    • 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.