※編集中ですが、コードだけでも共有しておきます。
#今回のコード
例
<?php
$postalCode = 1000001; //ここに好きな郵便番号を代入
$url = 'http://zipcloud.ibsnet.co.jp/api/search?zipcode=' . $postalCode; //下7桁が任意の郵便番号になったurlを$urlに代入
//urlからはファイルが返される
$resJson = file_get_contents($url); //ファイルの内容を文字列に読み込む
$resJson = mb_convert_encoding($resJson, 'UTF8', 'ASCII,JIS,UTF-8,EUC-JP,SJIS-WIN'); //文字化け防止
$res = json_decode($resJson,true); //第二引数を「true」にすると配列型に変換
//返ってきた文字列を、それぞれの変数に代入して整理していく
$prefecture = $res['results'][0]['address1'];
$city = $res['results'][0]['address2'];
$city2 = $res['results'][0]['address3'];
$zipcode = $res['results'][0]['zipcode'];
//出力
echo '郵便番号「' . $zipcode . '」は';
echo '<br>';
echo $prefecture . $city . $city2 . 'です。';
実行結果
郵便番号「1000001」は
東京都千代田区千代田です。