Hi everybody.
I used PHP to write a code that will sort the text, but when entered (either withing 5 seconds or with JavaScript turned off) I still can’t pass the test.
Here is the code:
```<?php
$string = “too, you, likely, with, every, who, his, than, neither, while, however, most, get, was, there, which, may, some, says, your, able, into, any, why, after, only, either, whom, then, these, her, other, can, when, ever, does, not, might, that, about, did, should, say, were, must, among, got, cannot, but”;// Let’s split it and add in array, for easier sort
$array = explode(“, ”,$string);// Sorting the mess
sort($array);// Wow, helper vars!?
$i=1;
$col=“”;// Aaaand.. the output
foreach($array as $word) {
if($i!==1) $col = “, ”;
echo $col . $word;
$i++;
}
?>
```And the result is:
able, about, after, among, any, but, can, cannot, did, does, either, ever, every, get, got, her, his, however, into, likely, may, might, most, must, neither, not, only, other, say, says, should, some, than, that, then, there, these, too, was, were, when, which, while, who, whom, why, with, you, your
Can you please explain me why the form won’t let me through? Is it a bug? Maybe a typo in my code?
Thank you in advance.
P.S. Really nice project. Of course design makes my eyes bleed, haha. No offense. :)
You copy the textarea content for your code string? Maybe is take many time. I suggest you learn join(), and msybe translate it to javsscript, and remove the spoiler.
?
Did you know that the list of words is not the same every time your reload the level’s page ?
You should, instead of initializing a string with precise words, check the level’s page, take the words, store them into string or array or everything you want and let the rest of the code sorting everything :p
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘\’‘ at line 1
Thanks @Mugiwara27 & @bolofecal Yes I just realized each time the textarea changes value. So I guess best way really would be JavaScript. I think now I know what to do :)
P.S. @bolofecal at this point I think for some other beginners It still is a hint, so I’ll leave it there. And aobut join. I know how to use join(), yet I did it oldschool-lazy way. :D
?
Hmm I think I am having the same problem where my word list is exactly initialized and I know that is a poor way of handling this challenge b/c the word list changes every time.
The way I sort the array currently uses: sort() with the double quotes for each element. I am trying to find another way to sort the array without having quotes or if the move would be to create a function that would put double quotes into the array, then sort it, then remove it, but I think that I am overthinking the problem..
Can you elaborate on what you meant by checking the level’s page, taking the words and storing that into a array?
(Working in JS here)
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘\’‘ at line 1