How to remove first whitespace of a string

一笑奈何 提交于 2019-11-29 12:15:49

If you have the contents as a string, just run ltrim.
It will strip away all the whitespaces from the starting of the string.

$str = ltrim($str);
Bogdan Burim

That is how to remove only the first whitespace:

$s   = '  Text';
$arr = str_split($s);
array_shift($arr);
$s   = implode('', $arr);

die($s);
Ed Jellard

I would delete up to the first hash -

$contents = substr($contents, 0, strpos($contents, "#") - 1)
GolezTrol

If you got this configuration in a string, as your title says, you can just trim the string.

$config = trim($config);
Valeriy Gorbatikov

You can use the PHP function trim.

Piyush Bansal

Put the following code on the first line of the file:

ob_start();

Put the following code just before you displaying the content:

ob_end_clean();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!