数组内容在通过HttpPost从Android传输到PHP时丢失

I am trying to send an array from Android to PHP. The array is a basic key-value pair (string, string) which consists of all the contacts from my device phonebook (name, phone_number). Here's the code snippet that does this:

HttpClient httpClient = new DefaultHttpClient();
                // post header
                HttpPost httpPost = new HttpPost(postReceiverUrl);
                int i=0;
                List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
                for(i=0;i<item.size();i++) {
                    nameValuePairs.add(new BasicNameValuePair(item.get(i).getName(), item.get(i).getNumber()));
                }
                Log.v("Count", ""+i); 
                try {
                    httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                    // execute HTTP post request
                    HttpResponse response = httpClient.execute(httpPost);
                    HttpEntity resEntity = response.getEntity();

                    if (resEntity != null) { 
                        String responseStr = EntityUtils.toString(resEntity).trim();
                        Log.v("TAG", "Response: " +  responseStr);  
                    }
                } catch (IOException e) {
                    e.printStackTrace();
                }

On PHP end, the code is meant to accept the data in POST and echo it out. The code goes:

    <?php

// Run script only if the dump array is received
if($_POST){

echo "server received: ".count($_POST);


// Read comma-separated text file
    $arr = 0;
    foreach($_POST as $names[$arr] => $numbers[$arr]) {
        $numbers[$arr] = preg_replace('/[^0-9]/','',$numbers[$arr]);
        $arr += 1;
    }
for($i=0;$i<$arr;++$i) {
    echo $i.".  ".$numbers[$i]."-------".$names[$i]."
";}
}
?>

This works perfect for smaller phonebooks. However, while running this on a phonebook with exactly 100 phone number entries, the echo dump shows only 87. What gives? I even tried using GET and REQUEST instead of POST but results remain the same.

It looks like issues is in form content type, which is application/x-www-form-urlencoded by default. Here is more information on form content types:

The content type "application/x-www-form-urlencoded" is inefficient for sending large quantities of binary data or text containing non-ASCII characters. The content type "multipart/form-data" should be used for submitting forms that contain files, non-ASCII data, and binary data.

Take a look here on how to use multipart/form-data instead: Post multipart request with Android SDK