打印多维数组

时间:2014-10-23 16:08:24

标签: php arrays

我正在配置一个作业板API并且已经将它打印到我可以打印完整阵列但我只想回应特定部分。

这是数组,我在2个条目后停止了以保持紧凑。

Array
(
[search_settings] => Array
    (
        [query] => Information Technology
        [location] => chicago
        [miles] => 15
        [sort] => dd
        [window_size] => 50
        [publisher_id] => 22222
        [search_style] => 2
        [configuration_flag] => r
        [auth] => 123456
        [client_ip] => 111.111.111.111
    )

[request_url] => http://api.simplyhired.com/a/jobs-api/xml_v2/q-Information+Technology/l-chicago/mi-15/ws-50/sb-dd
[request_title] => Information Technology Jobs - Chicago, IL
[request_time] => 2014-10-22 16:44:30 EDT
[start_index] => 0
[num_results] => 50
[total_results] => 20724
[total_viewable_results] => 778
[jobs_collection] => Array
    (
        [0] => Array
            (
                [job_key] => 7055.x0146017d3fd5
                [title] => Senior Information Security Manager
                [company_name] => Teambradley
                [company_url] => 
                [source] => JobServe Ltd
                [url] => http://api.simplyhired.com/a/job-details/view/jobkey-7055.x0146017d3fd5/rid-yvujgjnejabmuqwgjvmogcpatdfjkhue/cjp-0/hits-20724?icsrc=xml&rfr=partner
                [type] => organic
                [is_paid] => 
                [is_sponsored] => 
                [is_organic] => 1
                [location] => Chicago, IL
                [city] => Chicago
                [state] => IL
                [postcode] => 60624
                [county] => Cook County
                [region] => 
                [country] => US
                [date_last_seen] => 2014-10-22 13:11:50 EDT
                [date_that_posted] => 2014-10-22 13:11:50 EDT
                [description] => technical security control design, architecture, security technology implementation, information security solution engineering, etc. If you are interested in this job opportunity, contact TeamBradley today to learn more! WHEN RESPONDING TO...>
            )

        [1] => Array
            (
                [job_key] => 43374f83d8ee563c1f5d17128063425db4bc1052
                [title] => Instructor II
                [company_name] => General Dynamics Information Technology
                [company_url] => 
                [source] => General Dynamics Information Technology, Inc
                [url] => http://api.simplyhired.com/a/job-details/view/jobkey-43374f83d8ee563c1f5d17128063425db4bc1052/rid-yvujgjnejabmuqwgjvmogcpatdfjkhue/cjp-1/hits-20724?icsrc=xml&rfr=partner
                [type] => organic
                [is_paid] => 
                [is_sponsored] => 
                [is_organic] => 1
                [location] => Chicago, IL
                [city] => Chicago
                [state] => IL
                [postcode] => 60624
                [county] => Cook County
                [region] => 
                [country] => US
                [date_last_seen] => 2014-10-22 11:37:11 EDT
                [date_that_posted] => 2014-10-22 11:37:11 EDT
                [description] => Dynamics Information Technology provides information technology (IT), systems engineering, professional services ... been at a like-type and like-level facility. Additional Information Relocation No Security Clearance Level Background...>
            )

我想从job_collection数组的所有条目中回显标题,网址和城市。

我能够使用

回显数组第一部分的部分
echo $myArray[search_settings]['publisher_id'];

我还可以使用以下

来回显jobs_collection数组中的单个值
echo $jobs22[jobs_collection][0]['city'];

我假设我可以使用for或while循环,但我无法正常工作。

1 个答案:

答案 0 :(得分:3)

foreach ($jobs22[jobs_collection] as $job) {
  echo $job['title'] . ' in ' . $job['city'] . " @ " . $job['url'];
}

根据您的需要进行调整