$str=\':this is a applepie :) \';
How to use PHP, Remove the first character :
The code works well for me.
$str = substr($str ,-(strlen($str)-1));
Maybe, contribute with answers too.
you can use the sbstr() function
$amount = 1; //where $amount the amount of string you want to delete starting from index 0
$str = substr($str, $amount);
To remove every :
from the beginning of a string, you can use ltrim:
$str = '::f:o:';
$str = ltrim($str, ':');
var_dump($str); //=> 'f:o:'
$str = substr($str, 1);
See PHP manual example 3
echo substr('abcdef', 1); // bcdef
Note:
unset($str[0])
will not work as you cannot unset part of a string:-
Fatal error: Cannot unset string offsets
Here is the code
$str = substr($str, 1);
echo $str;
Output:
this is a applepie :)
use mb_substr function
mb_substr("我abc", 1);