- str_replace: documentation ( source)
- explode: documentation ( source)
- date: documentation ( source)
<?php
$today_y = date("Y");
$today_m = date("m");
$today_d = date("d");
list($birthday_y, $birthday_m, $birthday_d) = explode('/', str_replace('-','/',$birthday));
$age = $today_y - $birthday_y;
//誕生日前なら1才引く
if( $today_m*100 + $today_d < $birthday_m*100 + $birthday_d ){ $age--; }
echo $age;