取消 PHP 数组中的值以防止打印到屏幕

Unset() value from PHP Array To Prevent Print Out To Screen

我是一名 jr 开发人员,负责使用 API 检索网站数据的 wordpress 插件。 API 调用中包含同一页面上 Google 地图 API 的纬度和经度值。有一个 for 循环来打印 API 中提供的每个值。我想阻止此循环将提供的纬度和经度值打印到屏幕,同时仍将这些值提供给 Google 地图。想到了一些解决方案,但我不确定哪个是最好的解决方案...... 1.) 取消设置() for 循环点的纬度和经度值。也许这会阻止它将值应用于 Google 地图 API?

2.) 在 for 循环中设置一个 if 语句来监视这两个值——但这将在每次循环许多字段之一时检查这些值,这个解决方案是否从 performance/speed 的网站?

提前致谢

我希望数组映射是您要找的

$in=[
[
    'BathsFull' => 2, 
    'BathsHalf' => 1, 
    'BathsTotal' => 3, 
    'BedsTotal' => 4, 
    'Latitude' => 96.794636, 
    'Longitude' => -96.828915, 
    'ListPrice' => 729900
 ],
 [
    'BathsFull' => 2, 
    'BathsHalf' => 1, 
    'BathsTotal' => 3, 
    'BedsTotal' => 4, 
    'Latitude' => 96.794636, 
    'Longitude' => -96.828915, 
    'ListPrice' => 729900
 ]
];
print_r($in);
$out = array_map(function (array $arr) {unset($arr['Longitude'],$arr['Latitude']);return $arr;}, $in);
print_r($out);