【发布时间】:2019-06-01 10:32:44
【问题描述】:
我目前正在尝试为 PHP 中的某些 div 构建排序功能。首先,我将每个部分放入一个函数中,这样当我调用这个函数时,该部分就会被打印出来。
现在我的问题是我不知道如何根据他们的位置调用每个部分?这是我的代码:
$elements = array(
'section_one' => 6,
'section_two' => 1,
'section_three' => 0,
'section_four' => 3,
'section_five' => 2,
'section_six' => 5,
'section_seven' => 4
);
foreach ( $elements as $element => $position ) {
}
get_section_one( $a, $b, $c );
get_section_two( $a, $b, $c, $d );
get_section_three( $a, $b );
get_section_four( $a );
get_section_five( $a, $b, $c, $d, $e );
get_section_six( $a, $b, $c );
get_section_seven( $a, $b, $c );
每个函数都有不同的未定义参数。 $elements 数组有一个键,它是部分的名称和一个定义位置的值。
那么有谁知道我如何根据它们从最低数字到最高数字的位置来调用每个函数?
在我的示例中,section_three 必须是第一个应该被调用的元素...
【问题讨论】: