PHP Classes

multidimensional arrays

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  multidimensional arrays  
Subject:multidimensional arrays
Summary:Need to assign variables accessible from argument
Messages:2
Author:Billy R Baldwin
Date:2015-07-27 23:22:22
Update:2015-07-28 02:04:49
 

  1. multidimensional arrays   Reply   Report abuse  
Picture of Billy R Baldwin Billy R Baldwin - 2015-07-28 02:04:49
I need to find a way to assign variables to a multidimensional array coming from an associative array query. I have tried many methods, and can't seem to get it right. My current code is below.

class getIt{

//Query our content table using the built in JFactory class, and loadAssocList() function.
// this function returns an indexed array of objects from the table
public function getMainQuery(){

$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id', 'title', 'introtext', 'images', 'fulltext')));
$query->from($db->quoteName('#__content'));
$query->where($db->quoteName('state') . ' = '. $db->quote('1'));
$query->order('ordering DESC');
$db->setQuery($query);
$res = $db->loadAssocList();

foreach($res as $row => $innerArray){
foreach($innerArray as $innerRow => $value){

print_r($innerArray,$value);
}
}
}



}

In the end I essentially want to be able to use:
$list = new getIt();

echo $list->getMainQuery($arg1,$arg2));

Where $arg1 and $arg2 represent specific key and value I want to pass, to echo the values.

There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.