我有一个数组,我想从中删除第一级索引并保留它的值 是否有可能没有循环?
输入数组:
Array (
[0] => Array(
[2135] => Array(
[id] => 2135
[first_name] => John
[last_name] => Doe
)
),
[1] => Array (
[3245] => Array(
[id] => 3245
[first_name] => Sally
[last_name] => Smith
)
)
)
预期输出:
Array (
[2135] => Array(
[id] => 2135
[first_name] => John
[last_name] => Doe
),
[3245] => Array(
[id] => 3245
[first_name] => Sally
[last_name] => Smith
)
)
答案 0 :(得分:1)
试试这个
$a = array (
array(
'2135' => array(
'id' => 2135,
'first_name' => 'John',
'last_name' => 'Doe'
)
),
array (
'3245' => array(
'id' => 3245,
'first_name' => 'Sally',
'last_name' => 'Smith',
)
)
);
$reduce = function ($new = array(), $x) {
$new[array_keys($x)[0]]=array_values($x)[0];
return $new;
};
$output = array_reduce($a, $reduce);
// var_dump($output);
答案 1 :(得分:1)
简短(评论)回答:
shp.type
<强>输出:强>
Sub nameTheShapes()
Dim shp As Shape
For Each shp In Sheet1.Shapes
If shp.type = 1 Then
shp.TextFrame2.TextRange.Characters.Text = shp.ID
End If
Next
End Sub
答案 2 :(得分:0)
没有循环会很困难,但是可能的解决办法是:
$file_array = array();
foreach($array_name as $row =>$value){
foreach ($value as $row1 =>$value1){
if(in_array($value1, $file_array)){
}
else{
$file_array[] =$value1;
}
}
}