<?php

$path = $_SERVER['PATH_INFO'];

if ($path = '/address')
{
  $controller = new \Controller();
  $return = $controller->ex();
  echo $return;
}

class Controller
{
  $addresses = [];

  function ex()
  {
    $this->rcd();
    $id = $_GET['id']
    $address = $this->addresses[$id];
    return json_encode($address);
  }

  function rcd()
  {
    $file = fopen('example.csv', 'r');
    while (($line = fgetcsv($file)) !== FALSE) {
        $this->addresses[] = [
            name = $line[0],
            phone = $line[1],
            street = $line[2]
        ]
    }

    fclose($file);
  }
}
?>

<?php

$path = $_SERVER['PATH_INFO'];

if ($path = '/address')
{
  $controller = new \Controller();
  $return = $controller->ex();
  echo $return;
}

class Controller
{
  private $addresses = [];

  function ex()
  {
    $this->rcd();
    $id = $_GET['id'];
    $address = $this->addresses[$id];
    return json_encode($address);
  }

  function rcd()
  {
    $file = fopen('example.csv', 'r');
    while (($line = fgetcsv($file)) !== FALSE) {
        $this->addresses[] = [
            name => $line[0],
            phone => $line[1],
            street => $line[2]
        ];
    }

    fclose($file);
  }
}
?>

Make it parse (using PHP 5.5).
Make it parse (using PHP 5.5).
