I have this code:
$text = "12345678910";
$codebits = str_split($text ,3);
for($b = 0; $b<3; $b++){
echo "$codebits[$b]yes";
}
which outputs the result:
123yes456yes789yes
How can I change it to be in one line? For example:
123456789yes
I have this code:
$text = "12345678910";
$codebits = str_split($text ,3);
for($b = 0; $b<3; $b++){
echo "$codebits[$b]yes";
}
which outputs the result:
123yes456yes789yes
How can I change it to be in one line? For example:
123456789yes
Use substr() like below:-
<?php
echo substr($text,0,8)."yes";
Output:-https://eval.in/896033
Or if you want to use your one:-
<?php
$text = "12345678910";
$codebits = str_split($text ,3);
for($b = 0; $b<3; $b++){
echo "$codebits[$b]";
}
echo "yes";
Output:- https://eval.in/896040
if you must use str_split:
<?php
$text = "12345678910";
$codebits = str_split($text ,strlen($text)-2);
$codebits[1]="yes";
for($b = 0; $b<2; $b++){
echo "$codebits[$b]";
}
?>
And you can concatanate array $codebits:
$fullstring=$codebits[0].$codebits[1];
echo $fullstring;