<?php

$ip='192.168.0.1';

$e=explode('.',$ip);//split on the dot

echo $e[0].'.'.$e[1]; //glue back the first 2 pieces