There is a string "abc".
How on php by means of substr I get the second letter?
I write: substr('abc', 0, 2) , but does not help.
What am I doing wrong?
There is a string "abc".
How on php by means of substr I get the second letter?
I write: substr('abc', 0, 2) , but does not help.
What am I doing wrong?
The second letter is the letter number 1, since considered from scratch. If you need one letter. then the length = 1.
substr('abc', 1, 1) But if a string is a variable, not a literal, then it is also possible by index:
$a = 'abc'; $second_letter = $a[1]; uttf-8 and you need to use mb_* functions. - AndSource: https://ru.stackoverflow.com/questions/691894/
All Articles