title: PHP foreach update custom field
body: <p>I use ACF Pro google maps.
  The Plugin stores the map data in an array. So far so good.</p>
  <p>Now, I like to run through the array and directly store the date in new custom fields.</p>
  <p>This works, but I like to give the fields my own name, not the names from the ARRAY (lat &amp; lng).</p>
  <p>Can anyone explain how I can use my own names for the custom fields spot_lat &amp; spot_lng?</p>
  <pre class="lang-php prettyprint-override"><code>function my_copy_date_filter($post_id)
  {
    $post_type = get_post_type($post_id);
    if ($post_type != 'spot') {
      return;
    }
    $date = get_field('spot_location', $post_id);
    if ($date) {
      $lat_lng = [];
      foreach (array('lat', 'lng') as $i =&gt; $k) {
        if (isset($date[$k])) {
          update_post_meta($post_id, $k, $date[$k]);
        }
      }
    }
  }
  add_filter('acf/save_post', 'my_copy_date_filter', 20);
  </code></pre>
  <p>Thanks for any suggestion,<br />
  Denis</p>