I want to trim a String. Here is my code:
$base2 = chop($base,"www.");
$base contains www.example.com I want it to remove the www.
I thought that this would work. I think I have the latest PHP version.
Use str_replace():
$base2 = str_replace('www.', '', $base);
This replaces www.
with nothing, so it gets deleted.
chop
: http://php.net/manual/de/function.chop.php
I don't like replacing anywhere inside the string because you are asking to remove first characters only:
if (stripos($base,'www.') === 0)
{
$base = substr($base, 4);
}
stripos
to solve lower/upper cases.