PHP Warning: mysqli::real_escape_string() expects parameter 1 to be string, array given
<p>I'm getting a warning from <code>PHP</code>:</p>

<blockquote>
  <p>PHP Warning:  mysqli::real_escape_string() expects parameter 1 to be string, array given in ..</p>
</blockquote>

<p>The code giving the warning is:</p>

<pre><code>$saveData = array_map(array($connection, 'real_escape_string'), $saveData);
</code></pre>

<p>$saveData is decoded JSON taken from $_POST - typical dataset would be:</p>

<pre><code>array(22) {
  ["quoteID"]=&amp;gt;
  string(7) "GLY0YQ5"
  ["Inventory"]=&amp;gt;
  array(0) {
  }
  ["pickupLocation"]=&amp;gt;
  string(15) "EPPING NSW 2121"
  ["dropOffLocation"]=&amp;gt;
  string(17) "RICHMOND VIC 3121"
  ["pickupSuburb"]=&amp;gt;
  string(6) "EPPING"
  ["pickupPostcode"]=&amp;gt;
  string(4) "2121"
  ["pickupState"]=&amp;gt;
  string(3) "NSW"
  ["dropoffSuburb"]=&amp;gt;
  string(8) "RICHMOND"
  ["dropoffPostcode"]=&amp;gt;
  string(4) "3121"
  ["dropoffState"]=&amp;gt;
  string(3) "VIC"
  ["pickupLatitude"]=&amp;gt;
  string(10) "-33.772549"
  ["pickupLongitude"]=&amp;gt;
  string(10) "151.082365"
  ["dropoffLatitude"]=&amp;gt;
  string(10) "-37.818587"
  ["dropoffLongitude"]=&amp;gt;
  string(10) "144.999181"
  ["pickupDistance"]=&amp;gt;
  string(1) "0"
  ["pickupAccess"]=&amp;gt;
  string(1) "0"
  ["dropoffDistance"]=&amp;gt;
  string(1) "0"
  ["dropoffAccess"]=&amp;gt;
  string(1) "0"
  ["regionalLoading"]=&amp;gt;
  string(1) "0"
  ["totalVolume"]=&amp;gt;
  string(2) "39"
  ["totalDistance"]=&amp;gt;
  string(3) "897"
  ["totalPrice"]=&amp;gt;
  string(4) "3120"
}
</code></pre>

<p>My understanding is the issue is <code>mysqli</code> expecting the first parameter to be the <code>$connection</code> variable, which it actually is, it's just different to the regular <code>mysqli</code> format because of the format required by <code>array_map</code>.</p>

<p>Given the outcome desired is the <code>real_escape</code> the entire array in one shot, and that the <code>error</code> is just a <code>warning</code> and is actually working, is there a better way to do this, and is it even necessary to make an adjustment?</p>