如何只回显$ categories数组中的一个标题

时间:2012-10-14 19:04:40

标签: php

希望有人可以通过$ categories数组中的多个标题来回复“title_2 with books1,...”

示例数组:

$categories= array(

'title_1' => "Books", 
"books1" => array( "Books1", "set1", "type"), 
"books2" => array( "books2", "set1", "type"), 
"books3" => array( "books3", "set5", "type"),

'title_2' => "Books_2", 
"books1" => array( "Books1", "set1", "type"), 
"books2" => array( "books2", "set1", "type"), 
"books3" => array( "books3", "set5", "type"),

'title_3' => "Books_3", 
"books1" => array( "Books1", "set1", "type"), 
"books2" => array( "books2", "set1", "type"), 
"books3" => array( "books3", "set5", "type"),
,....
);

由于

1 个答案:

答案 0 :(得分:1)

这很容易......

$categories= array(

'title_1' => "Books", 
"books1" => array( "Books1", "set1", "type"), 
"books2" => array( "books2", "set1", "type"), 
"books3" => array( "books3", "set5", "type"),

'title_2' => "Books_2", 
"books1" => array( "Books1", "set1", "type"), 
"books2" => array( "books2", "set1", "type"), 
"books3" => array( "books3", "set5", "type"),

'title_3' => "Books_3", 
"books1" => array( "Books1", "set1", "type"), 
"books2" => array( "books2", "set1", "type"), 
"books3" => array( "books3", "set5", "type"),

);


echo "<pre>";
echo $categories['title_2'] , "\n"  , implode(",",$categories['books1']);

输出

Books_2
Books1,set1,type