首页 > 解决方案 > 如何从数组php中检索数据

问题描述

当我使用我的代码时:

即将到来的数据会是这样的

Array
(
    [name] => Facebook
    [author] => Facebook
    [physicalAddress] => 1 Hacker Way\nMenlo Park, CA 94025
    [supportEmail] => android-support@fb.com
    [supportUrl] => https://www.facebook.com/facebook
    [category] => Social
    [storeCategory] => SOCIAL
    [price] => 0
    [changelog] => • Improvements for reliability and speed
    [datePublished] => April 11, 2019
    [datePublishedIso] => 2019-04-11T00:00:00Z
    [fileSize] => Varies with device
    [numDownloads] => 1,000,000,000+
    [versionName] => Varies with device
    [operatingSystems] => Varies with device
    [contentRating] => Parental guidance
)

我想单独获取数据

喜欢

姓名、作者等

我该怎么办?

标签: phparrayskey

解决方案


很简单。这是您的操作方法:

<?php

$details = array(
'name' => 'Facebook',
'author' => 'Facebook',
'physicalAddress' => '1 Hacker Way\nMenlo Park, CA 94025',
'supportEmail' => 'android-support@fb.com',
'supportUrl' => 'https://www.facebook.com/facebook',
'category' => 'Social',
'storeCategory' => 'SOCIAL',
'price' => '0',
'changelog' => '&#x2022; Improvements for reliability and speed',
'datePublished' => 'April 11, 2019',
'datePublishedIso' => '2019-04-11T00:00:00Z',
'fileSize' => 'Varies with device',
'numDownloads' => '1,000,000,000+',
'versionName' => 'Varies with device',
'operatingSystems' => 'Varies with device',
'contentRating' => 'Parental guidance',
);
?>

<p><strong>Name: </strong><?php echo $details['name']; ?></p>
<p><strong>Author: </strong><?=$details['author']; ?></p>
<p><strong>Date Published ISO: </strong><?php echo $details['datePublishedIso']; ?></p>

推荐阅读