-2

hope someone can help with echo only "title_2 with books1,..." from multiple titles in $categories array

example arrays:

$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"),
,....
);

Thanks

4

1 回答 1

1

This is very easy ....

$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']);

Output

Books_2
Books1,set1,type
于 2012-10-14T19:08:50.427 回答