<?php
echo '<pre>';
$directnames = array("LN"=>"ListingId","LAG"=>"AgentCode","ST"=>"MlsStatus","LP"=>"ListPrice","PIC"=>"PhotosCount");
$result = array("LN"=>"129_551453","LAG"=>"2.50","ST"=>"3.00","LP"=>"Ferndale","PIC"=>"359900.00");
$directnames_getkeys = array_keys($directnames);
$result_getkeys = array_keys($result);
$merge_keys = array_intersect($directnames_getkeys,$result_getkeys);
$assigning = array();
foreach($merge_keys as $preparevalues){
foreach($directnames[$preparevalues] as $keys){
echo $assigning[$keys] = $result[$preparevalues];
}
}
echo '</pre>';
?>
Expected output:
array(
"ListingId"=>"129_551453",
"AgentCode"=>"2.50",
"MlsStatus"=>"3.00",
"ListPrice"=>"Ferndale",
"PhotosCount"=>"359900.00"
)
try
array_combine()
output:
Array ( [ListingId] => 129_551453 [AgentCode] => 2.50 [MlsStatus] => 3.00 [ListPrice] => Ferndale [PhotosCount] => 359900.00 )