$beforeDot = array_shift(explode('.', $string)); $beforeDot = current(explode(".", $string)); // PHP <= 5.3: $beforeDot = explode(".", $string); $beforeDot = $beforeDot[0];