How to get a string one character at a time
$line = "Hello";
function getChar($line){
for ($i = 0, $j = strlen($line); $i < $j; $i++) {
echo $line[$i].', ';
}
Written by Yesi D
Related protips
2 Responses
Hi there, php has a built in for this "str_split".
foreach(str_split('this is a bit cleaner') as $s){
echo $s .', ';
}
all the best
Ross
over 1 year ago
·
@rosscdh thanks! :)
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Php
Authors
Related Tags
#php
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#