Shouldn’t you then replace `strlen($arg)` with `$len`?