Getting the first character of a string with $str[0]

前端 未结 9 1106
余生分开走
余生分开走 2020-11-28 21:04

I want to get the first letter of a string and I\'ve noticed that $str[0] works great. I am just not sure whether this is \'good practice\', as that notation is

9条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-28 22:04

    I've used that notation before as well, with no ill side effects and no misunderstandings. It makes sense -- a string is just an array of characters, after all.

提交回复
热议问题