如何获得Aray的价值

时间:2019-03-11 13:43:11

标签: magento2.2.2

 Array
 (
[0] => Array
    (
        [value] => 0
        [label] => NOT LOGGED IN
    )

[1] => Array
    (
        [value] => 1
        [label] => General
    )

[2] => Array
    (
        [value] => 2
        [label] => Wholesale
    )

[3] => Array
    (
        [value] => 3
        [label] => Retailer
    )

[4] => Array
    (
        [value] => 4
        [label] => Basic Purchase
    )

[5] => Array
    (
        [value] => 5
        [label] => Purchase Group
    )

[6] => Array
    (
        [value] => 6
        [label] => Payment Failed Group
    )

[7] => Array
    (
        [value] => 7
        [label] => Cancel Group
    )

[8] => Array
    (
        [value] => 8
        [label] => Partner Pricing
    )

[9] => Array
    (
        [value] => 9
        [label] => Expert User Group
    )

 )

我现在要得到这个数组,我希望所有标签值只是在数组中标记值,并希望我们在数组中。

3 个答案:

答案 0 :(得分:0)

请检查http://php.net/manual/de/function.array-column.php

这应该有效:

$labels = array_column($array, 'label');
print_r($labels);

对于Magento系列,您可以使用...

$collection->getColumnValues('label')

答案 1 :(得分:0)

获取付款方式标签

foreach ($array as $value) 
{
 $all_labels=$value['label'];
}

答案 2 :(得分:0)

$labelarray = array();
foreach ($valuearray as $value) 
{
   $labelarray[] = $value['label'];
}
print_r($labelarray);