+ 1
Help me in converting string to array in PHP
I want to convert a string into an array without using any functions like explode(), mb_strlen(), strlen(). By only using loop and conditional statements. Input will be like "Hello world" Expected output [0]=>Hello [1]=>world
4 Answers
+ 3
You can use this code. I didn't use even the strlen(). However, I should have used the empty() built-in function.
https://code.sololearn.com/wa21a22A46a2
+ 2
Splits the string into character array and use `count()` to get length.
(Edit)
Modified by removing array(), count(), str_split(), and unset()
https://code.sololearn.com/wCFEXlVre14G/?ref=app
+ 1
Thanks for your good code. But I think the idea is not using any built-in function.
+ 1
Now it's fixed without built-in function.