I have an array with a couple of words, and I'm trying to explode it at only one whitespace, but its counting whitespaces in as well when exploding for some reason. How do I stop this?
<?php
$string = "I'm just so peachy, right now";
$string = explode(" ", $string);
$count = count($string);
$tempCount = 0;
while ($tempCount < $count) {
echo $string[$tempCount]."$tempCount<br>";
$tempCount++;
}
?>
Actual Output:
I'm0
just1
2
3
4
5
6
7
8
9
10
11
12
so13
peachy,14
right15
now16
Expected Output:
I'm0
just1
so2
peachy,3
right4
now5