Avatar

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

by Micha ⌂, Wednesday, September 11, 2019, 13:28 (1682 days ago) @ Auge

Hi,

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.

What is your intention of the foreach-loop? The foreach-loop is a loop over all elements in then array. So, you first check the limit (e.g. 9 elements), and than you create a deep copy of the array containing all elements?!

/Micha

--
applied-geodesy.org - OpenSource Least-Squares Adjustment Software for Geodetic Sciences


Complete thread:

 RSS Feed of thread