我需要从此代码中获取标题摘要封面值。请帮助我获取rawdata的值,我需要循环它们。 有人可以帮帮我
Array
(
[rawData] => Array
(
[csrf_hash_name] => 57b9481862e81cf2ebe9ed4e962355db
[title] => gfgf
[summary] => hfdhfhfdhdf
[cover] => clockface - 2.png
[id] => Array
(
[0] =>
[1] =>
)
)
答案 0 :(得分:1)
只需按键调用:
$arr = Array
(
'rawData' => Array
(
'csrf_hash_name' => 57b9481862e81cf2ebe9ed4e962355db,
'title' => gfgf,
'summary' => hfdhfhfdhdf,
'cover' => clockface - 2.png,
'id' => Array
(
0 => '',
1 => ''
)
);
然后使用
$title = $arr['rawData']['title'];
$summary = $arr['rawData']['summary'];
答案 1 :(得分:0)
请尝试以下代码
<?php
$array = array(
"rawData" => array(
"csrf_hash_name" => "57b9481862e81cf2ebe9ed4e962355db",
"title" => "gfgf",
"summary" => "hfdhfhfdhdf",
"cover" => "clockface - 2.png",
"id" => array(
0 => "",
1 => ""
)
)
);
foreach($array["rawData"] as $key => $arr) {
$fetchValue = array('title', 'summary', 'cover');
if(in_array($key, $fetchValue)) {
$$key = $arr;
}
}
echo $title;
echo $summary;
echo $cover;
?>
干杯!
答案 2 :(得分:0)
<?php
$array = array(
"rawData" => array(
"csrf_hash_name" => "57b9481862e81cf2ebe9ed4e962355db",
"title" => "gfgf",
"summary" => "hfdhfhfdhdf",
"cover" => "clockface - 2.png",
"id" => array(
0 => "",
1 => ""
)
)
);
$arr2 = array();
foreach($array["rawData"] as $key => $arr) {
$fetchValue = array('title', 'summary', 'cover');
if (in_array($key, $fetchValue)) {
$arr2[$key] = $arr;
}
}
extract($arr2);
echo $title;
echo '<br/>';
echo $summary;
echo '<br/>';
echo $cover;
?>