$data = "xxxxxxx_16.html"; $id = stristr( substr(strrchr( $data, "_"), 1), ".", true); echo $id; // 16