title: Using mysql_real_escape_string in a multidimensional array in php
body: <p>I am working on a big script which will generate some <strong>string</strong> or <strong>array</strong>  or <strong>multidimensional array</strong> i want use <strong><code>mysql_real_escape_string</code></strong> for all array / string
  for that this i tried the below code </p>
  
  <pre><code>function check($data) {
      if(!is_array($data)) {
          return mysql_real_escape_string($data);
      } else if (is_array($data)) {
         $newData = array();
         foreach($data as $dataKey =&gt; $dataValue){
               if(!is_array($dataValue)){
                   $key = mysql_real_escape_string($dataKey);
                   $value = mysql_real_escape_string($dataValue);
                   $newData[$key] = $value;
               }
          }
          return $newData;
       }  
  }
  </code></pre>
  
  <p>if i use like this <code>check('saveme');</code> this returns value</p>
  
  <p>if i pass a array it returns corrent value [ <code>check(array('a','b','c',1,2,3))</code> ]</p>
  
  <p>if i pass multidimensional array i get [<code>check(array(array('a',array('a','b','c',1,2,3),'c',1,2,3),'b',array('a','b','c',1,2,3),1,2,3))</code>]</p>
  
  <p>A kind note i want to use mysql_real_escape_string for array key too.</p>