PHP使用函数或类根据数组值在数组中创建数组

时间:2018-11-20 05:48:03

标签: php arrays function class sorting

我想使用php函数或php类将第一个数组的输出输出到第二个数组-
我应该在这里加上-

  
      
  1. “ deli”键的值“ |”是“名称”键值的分隔符。
  2.   
  3. 如果数组中“ attr”键的值为“ 32”,则该数组有子级,并在“ title”中添加子级。
  4.   
$Y=array(array('name' => "Family1",'attr' => array(64,8),'deli' => "|"),array('name' => "Family2",'attr' => array(32,8),'deli' => "|"),array('name' => "Family2|Parents1",'attr' => array(64,8),'deli' => "|"),array('name' => "Family2|Parents3",'attr' => array(32,8),'deli' => "|"),array('name' => "Family2|Parents3|Children",'attr' => array(32,8),'deli' => "|"),array('name' => "Family2|Parents3|Children|ChildOfChild",'attr' => array(64,8),'deli' => "|"),array('name' => "Family4",'attr' => array(32,8),'deli' => "|"),array('name' => "Family4|Child",'attr' => array(64,8),'deli' => "|"));

$Y2=array(array('name' => "Family1",'title' => "Family1",'attr' => array(64,8),'deli' => "|"),array('name' => "Family2",'title' => "Family2",'attr' => array(32,8),'deli' => "|",'child' =>     array('name' => "Family2|Parents1",'title' => "Parents1",'attr' => array(64,8),'deli' => "|"),array('name' => "Family2|Parents3",'title' => "Parents3",'attr' => array(32,8),'deli' => "|",'child' =>   array('name' => "Family2|Parents3|Children",'title' => "Children",'attr' => array(32,8),'deli' => "|",'child' =>    array('name' => "Family2|Parents3|Children|ChildOfChild",'title' => "ChildOfChild",'attr' => array(64,8),'deli' => "|")))),array('name' => "Family3",'title' => "Family3",'attr' => array(64,8),'deli' => "|"),array('name' => "Family4",'title' => "Family4",'attr' => array(32,8),'deli' => "|",'child' => array('name' => "Family4|Child",'title' => "Child",'attr' => array(64,8),'deli' => "|")));

0 个答案:

没有答案