php – How to arrange 2 simple array data-ThrowExceptions

Exception or error:

I have array data attached in below image and i want to show it exactly like

screenshot

Array
(
[0] => Array
    (
        [title] => VALID Act Introduction Advances Diagnostics Regulatory Reform
        [link] => https://www.advamed.org/newsroom/press-releases/valid-act-introduction-advances-diagnostics-regulatory-reform
    )

[1] => Array
    (
        [name] => MedTech Fighting Coronavirus on Multiple Fronts
        [category] => https://www.advamed.org/newsroom/press-releases/medtech-fighting-coronavirus-multiple-fronts
    )

[2] => Array
    (
    [title] => EPA Ethylene Oxide Value at Odds with Public Health, Best Science
    [link] => abc
    )
)
How to solve:

Lets say your first data stored in $Title array and second one stored in $Link array. Now populate those in $Data array.

$Data = [];
foreach($Title as $key=>$value){
      $Data[] = [
                  'title'=>$value,
                  'link'=>$Link[$key]
                ];
}

in $Data you’ll get your desired output.

Answer´╝Ü

so finally below is my solution. we just need to sort it out with array map function.

$results = array_map(null , $title, $url);

Leave a Reply

Your email address will not be published. Required fields are marked *