Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Sort array problem

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #171781
    matthisco
    Participant

    Hello,

    I have an array, and I would like to echo out each element depending up the value of one of the values, and put it a div for each category, not a div for each key, here is my code:

    // get max key
    $key = max($data['_searchResultContainer']);
    
    // loop through array, looking for category
    for ($i = 0; $i <= $key; $i++) {
    
    if (($data['_searchResultContainer'][$i]['cssprefix'] = 'kbsearch')){
    
    // if category is kbsearch then put it in a div
    echo "<div>";
    echo $data['_searchResultContainer'][$i]['subject'];
    echo $data['_searchResultContainer'][$i]['url'];
    echo $data['_searchResultContainer'][$i]['contentstext'];
    echo "</div>";
    
    }else if (($data['_searchResultContainer'][$i]['cssprefix'] = 'differentcategory')){
    
    // if category is differentcategory then put it in a div
    echo "<div>";
    echo $data['_searchResultContainer'][$i]['subject'];
    echo $data['_searchResultContainer'][$i]['url'];
    echo $data['_searchResultContainer'][$i]['contentstext'];
    echo "</div>";
             }
    }
    
    #171843
    __
    Participant

    what is the problem? do you have a question?

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.