1

I need to fetch Title summary cover values from this code. Please help me out in fetching the values of rawdata and I need to loop them. Can someone pls help me out

Array
    (
        [rawData] => Array
            (
                [csrf_hash_name] => 57b9481862e81cf2ebe9ed4e962355db
                [title] => gfgf
                [summary] => hfdhfhfdhdf
                [cover] => clockface - 2.png
                [id] => Array
                    (
                        [0] => 
                        [1] => 
                    )


    )

3 Answers 3

1

just call it by its key:

$arr = Array
(
    'rawData' => Array
        (
            'csrf_hash_name' => 57b9481862e81cf2ebe9ed4e962355db,
            'title' => gfgf,
            'summary' => hfdhfhfdhdf,
            'cover' => clockface - 2.png,
            'id' => Array
                (
                    0 => '',
                    1 => ''
                )


);

and then use

$title = $arr['rawData']['title'];
$summary = $arr['rawData']['summary'];
Sign up to request clarification or add additional context in comments.

Comments

0

Try this code below

<?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;
?>

Cheers!

Comments

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;
?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.