user3629794 user3629794 - 2 months ago 4x
PHP Question

PHP split string

Hey how can I split string into 2 string, exemple:

$ipadd = "";

From here I want to print 2 result,
one is: 192.168.1
secend is:60

Always split by the last point and print 2 string.


Everything after the last period:

echo substr(strrchr($ipadd, '.'), 1);

To get everything before it, you first need the position:

$pos = strrpos($ipadd, '.');
echo substr($ipadd, 0, $pos);