Avatar

Search Phrase Drops to 3 Words When Clicking Second Page (Bugs)

by Auge ⌂ @, Wednesday, September 11, 2019, 11:10 (13 days ago) @ Magma

Hello

So the thing is that the search is obviously limited to three words but one can input more than the three allowed words.


Ok, I've never seen that before on other websites.

I don't know, why Alex introduced this limit and I see several cases, when I would like to be able to input a longer sequence. Take the statement from my last posting as an assumption.

Is it just a matter of changing these numbers then?

// limit to 3 words:
if (count($search_array) > 3) {
for ($i = 0; $i < 3; ++$i) {

Yes, that's in general all.

    // limit to 3 words:
    if (count($search_array) > 3) {
        for ($i = 0; $i < 3; ++$i) {
            $stripped_search_array[] = $search_array[$i];
        }
        $search_array = $stripped_search_array;
    }

If we decide to raise the limit only the numbers have to change. In my example I replaced the hardcoded number with a variable.

    // limit to X ($limit) words:
    $limit = 9; // Fictional variable with the new limit for the amount of words.
    if (count($search_array) > $limit) {
        for ($i = 0; $i < $limit; ++$i) {
            $stripped_search_array[] = $search_array[$i];
        }
        $search_array = $stripped_search_array;
    }

Additionally I would replace the for loop with a foreach loop. That way there would be only a single point to set and use the limiting number.

    // limit to X ($limit) words:
    $limit = 9; // Fictional variable with the new limit for the amount of words.
    if (count($search_array) > $limit) {
        foreach ($search_array as $search_item) {
            $stripped_search_array[] = $search_item;
        }
        $search_array = $stripped_search_array;
    }

If we would decide to abolish the limit on the other hand, we could remove the whole block.

Tschö, Auge

--
Trenne niemals Müll, denn er hat nur eine Silbe!


Complete thread:

 RSS Feed of thread

powered by my little forum