lbarcelo Posted September 29, 2016 Share Posted September 29, 2016 Hi Larry, First of all, thanks for the book. It's being surprisingly easy to follow. I'm currently going through chapter 07 (arrays) and I was doing the excercise in "Transforming Between Strings and Array", I first created my list.html file and then on the list.php, this is what I wrote (HTML omitted): <?php //Get text from form $sorted_words = explode(' ',$_POST['words']); //Sort values sort($sorted_words); //Turn array back into a string $string_words = implode("<br />",$sorted_words); //Prints string print "<p>Alphabetized version of your text: <br />$string_words</p>"; ?> Everything working fine. However, the moment I add something else as separator: $sorted_words = explode(',',$_POST['words']); It prints out the phrase exactly as entered in the form, nothing seems to happen, no errors either. Where is the problem? PS: I've seen you are currently working on the 5th edition of "PHP and MySQL for Dynamic Web Sites". Any updates of how is it going? Planning to buy it as song as it gets published Many thanks in advance, Luis. Link to comment Share on other sites More sharing options...
Larry Posted October 15, 2016 Share Posted October 15, 2016 Thanks for the nice words! I really appreciate it. As for your question, if the separator isn't found than there's nothing to explode the next on so the result is the same as the input. In other words, if I explode abcdefghijk on %, the result is abcdefghijk. I haven't started the 5th edition of the PHP & MySQL book yet, so it won't be out for at least 6 months from now. But thanks for your interest! Link to comment Share on other sites More sharing options...
Recommended Posts