更改数组内的值

Change value inside an array

我想更改数组的值。

目前我的数组如下所示:

Array
(
    [0] => Array
        (
            [0] => 12-Multi_select-customfield-retina-ready+Yes
            [1] => 12-Multi_select-customfield-retina-ready+N/A
            [2] => 12-Multi_select-customfield-retina-ready+No
        )

)

我想删除 + 符号之前的所有内容,所以最后新数组看起来像这样

Array
(
    [0] => Array
        (
            [0] => Yes
            [1] => N/A
            [2] => No
        )

)

这是我的代码:

        $new_array = array();

        foreach( $array as $key => $value ) {

            $split = explode("+", $value[0]);               
            $new_array[] = $split[1];   

        }

希望它能起作用,但是当我检查新数组时,它只显示一个值。

Array
(
    [0] => Yes
)   

非常感谢任何帮助我走向正确方向的帮助。

请检查一下:

<?php
$array[0][0] = '12-Multi_select-customfield-retina-ready+Yes';
$array[0][1] = '12-Multi_select-customfield-retina-ready+N/A';
$array[0][2] = '112-Multi_select-customfield-retina-ready+No';

echo '<pre>';
print_r($array);

$new_array = array();

foreach( $array[0] as $key => $value ) {

    $split = explode("+", $value);
    $new_array[] = $split[1];

}
print_r($new_array);

echo '</pre>';

即使您在原始数组中有多个键,也请尝试这项工作 $original_array[0]$original_array[1] ...:

$original_array[0] = [
    0 => '12-Multi_select-customfield-retina-ready+Yes',
    1 => '12-Multi_select-customfield-retina-ready+N/A',
    2 => '12-Multi_select-customfield-retina-ready+No'
];
print_r($original_array); 

$new_array = [];
foreach ($original_array as $key => $value) {
    foreach ($value as $index => $val) {
        $split = explode("+", $val);
        $new_array[$key][] = $split[1];
    }
}

print_r($new_array);

示例:
Original array

Array
(
    [0] => Array
        (
            [0] => 12-Multi_select-customfield-retina-ready+Yes
            [1] => 12-Multi_select-customfield-retina-ready+N/A
            [2] => 12-Multi_select-customfield-retina-ready+No
        ),
   [1] => Array
        (
            [0] => 12-Multi_select-customfield-retina-ready+Yes
            [1] => 12-Multi_select-customfield-retina-ready+N/A
            [2] => 12-Multi_select-customfield-retina-ready+No
        )
)  

New Array

Array
(
    [0] => Array
        (
            [0] => Yes
            [1] => N/A
            [2] => No
        ),
    [1] => Array
        (
            [0] => Yes
            [1] => N/A
            [2] => No
        )
)