Array Item Referring to Another Sibling Element
質問
Can i do this in PHP, or any others way around ? I want to refer to another element in the array.
$config = array(
'factory-code' => array(
'01', '02'
),
'commodity-filter' => array(
'factory' => array(
'steel' => array( $this->factory-code ),
),
'branch' => array(
'steel' => array( $this->factory-code, '09' ),
)
)
);
解決
You'll have to create the factory-code in a separate array
$factory_code => array('01', '02');
$config = array(
'factory-code' => $factory_code,
'commodity-filter' => array(
'factory' => array(
'steel' => array( $factory_code ),
),
'branch' => array(
'steel' => array( $factory_code, '09' ),
)
)
);
所属していません StackOverflow