String to Array and Back

后端 未结 9 2476
自闭症患者
自闭症患者 2020-12-22 07:19

I have a string, how do I convert it to an array?

After manipulating that array, how do I again make it into a string?

Do strings in PHP behave the same way

9条回答
  •  温柔的废话
    2020-12-22 07:34

    In Java you can do String.tocharArray() which converts the string into an array of characters. You can do a String.split(regex) to split by a regular expression, returning a String array. A char array or String array can be looped on easily to convert back to a string.

    I'm not sure what you mean by "do they behave the same". Essentially they provide the same functionality... however in Java a String is an object that can be iterated upon if need be.

提交回复
热议问题