Announcement

Collapse
No announcement yet.

PHP while loop stop after one loop.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP while loop stop after one loop.

    Hi Guys,

    Ok , I need this while loop to stop after it picks my search terms at random. Right now the page loads new terms everytime the page is loaded. I need it to choose the terms at random and then keep the terms locked after they are picked. Hope that makes sense.

    else {
    function custom_shuffle($my_array = array(),$elements) {
    $copy = array();
    while ( $counter < $elements) { // takes a rand array elements by its key
    $element = array_rand($my_array); // assign the array and its value to an another array
    $copy[$element] = $my_array[$element]; //delete the element from source array
    unset($my_array[$element]);
    $counter = $counter+1 ;
    }
    return $copy;
    }

    $search_terms = array("");
    $ST_length = 4 ;
    $search_terms = (custom_shuffle($search_terms, $ST_length));
    //$Title = implode (' | ', $search_terms);
    //$pageTitle = "";
    //$pageHeading = "";

    $pageTitle = ucwords(implode (' | ', $search_terms));
    $pageHeading = ucwords(implode (' | ', $search_terms));
    $metaD="";
    $metaKeywords="";
    }


    Any ideas are greatly appreciated!
Working...
X