how to fetch district name on behalf pincode ?????

Discussion in 'PHP' started by dineshsingh1984, Oct 22, 2014.

  1. #1
    I want to get district name from the php library or online when enter pincode. because i don't have district name in my database.

    so please tell me logic or api name or library file.........
     
    dineshsingh1984, Oct 22, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    I'm assuming you're thinking of postal information here? Area-codes and -name/districts? If so, just get a hold of the dataset you need - usually it's available (for a fee) from the national post office in your region. If not, I'd recommend searching Google. If you can get a hold of the information, importing it into your database shouldn't be too hard.
     
    PoPSiCLe, Oct 22, 2014 IP
  3. Keteki

    Keteki Active Member

    Messages:
    112
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    90
    #3
    The below php code might help you,

    <?php
    $pin = 'put here the pin code';
    $get = 'http://pin-codes.in/api/pincode/'.$pin;
    $result = file_get_contents($get);
    for ($i=0;$i<30;$i++){
    $homepage = strstr($result, '{');
    $district = explode('District":"', $homepage);
    $district = explode('","State', $district[1]);
    $district = trim($district[0]);}
    echo "District: ".$district;
    ?>
    PHP:
     
    Keteki, Nov 10, 2014 IP