How come the $words variable contain the value "1" ?
I see this:
Content: word 1 word 2 word 3 word 4 word 5
Array ( [0] => word 1 [1] => word [2] => 2 [3] => word 3 [4] => word [5] => 4 [6] => word 5 ) words: 1
Anyway, I am trying to get each word from $content lined up like this:
word 1
word 2
word 3
word 4
word 5
How do I do it ? Any code sample appreciated.
Replacing the print_r with var_dump not good, either. :chomp: As I see this:
Content: word1 word 2 word3 word 4 word5
array(7) { [0]=> string(5) "word1" [1]=> string(4) "word" [2]=> string(1) "2" [3]=> string(5) "word3" [4]=> string(4) "word" [5]=> string(1) "4" [6]=> string(5) "word5" } words:
No good:
Neither no good just echoing the $words value as I see this:
Content: word1 word 2 word3 word 4 word5
Notice: Array to string conversion in C:\xampp\htdocs\project\explode.php on line 8
words: Array
And, no good this, either:
Thanks
PHP:
<?php
$content = "word1 word 2 word3 word 4 word5";
echo "Content: $content<br>";
$words = print_r(explode(" ", $content));
echo "words: $words";
?>
Content: word 1 word 2 word 3 word 4 word 5
Array ( [0] => word 1 [1] => word [2] => 2 [3] => word 3 [4] => word [5] => 4 [6] => word 5 ) words: 1
Anyway, I am trying to get each word from $content lined up like this:
word 1
word 2
word 3
word 4
word 5
How do I do it ? Any code sample appreciated.
Replacing the print_r with var_dump not good, either. :chomp: As I see this:
Content: word1 word 2 word3 word 4 word5
array(7) { [0]=> string(5) "word1" [1]=> string(4) "word" [2]=> string(1) "2" [3]=> string(5) "word3" [4]=> string(4) "word" [5]=> string(1) "4" [6]=> string(5) "word5" } words:
No good:
PHP:
<?php
$content = "word1 word 2 word3 word 4 word5";
echo "Content: $content<br>";
$words = var_dump(explode(" ", $content));
echo "words: $words";
?>
Content: word1 word 2 word3 word 4 word5
Notice: Array to string conversion in C:\xampp\htdocs\project\explode.php on line 8
words: Array
And, no good this, either:
PHP:
<?php
$content = "word1 word 2 word3 word 4 word5";
echo "Content: $content<br>";
$words = (explode(" ", $content));
echo "words: $words";
?>
Thanks