Remove empty space only from the beginning of php line

I have a line as shown below

$string = ' florida'

how can I remove the empty space from the beginning ONLY to form it as shown below.

$result_string = 'florida'

I'm sorry if this is too easy a question.

+8
source share
4 answers
$string = ' florida'

$result_string = ltrim($string);

echo $result_string;// it will remove white spces from beganing
+19
source

sounds like ltrim()- this is what you are looking for:

Separate spaces (or other characters) from the beginning of the line.

+9
source

trim()

:

trim - ( )

, ltrim ( Oezi) ( )

+2

:

$ string = trim ('florida');

echo $ string; //

: http://php.net/manual/en/function.trim.php

0

All Articles