PHP Two-dimensional array, how to solve

Source: Internet
Author: User
PHP Two-dimensional array

$str = Array (
"Network Programming book" =>array (' a ', ' d ', ' er '),
"History book" =>array (' Boko ', ' fd ', ' Popo '),
"Literature book" =>array (' fd ', ' fd ', ' fd '),

echo $str [0][2];

Why not show

Of course not show! No subscript 0, how to display?
Because you were 0 of the place was replaced by ' network programming books '
echo $STR [' Network Programming book '][2]
You this two-dimensional array, the outermost time the associative array subscript is the character channeling is not a number
You can change the code to
$str = Array (
Array (' A ', ' d ', ' er '),//network programming Book
Array (' Boko ', ' fd ', ' Popo '),//history book
Array (' fd ', ' fd ', ' fd '),//literature book

echo $str [0][2];
This will show the

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