user3629794 user3629794 - 11 months ago 90
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);