The model records have a reference to the $CI object in it which causes a recursive loop when printed out to the screen and may explain your blank screen. Does echo count($cheeses); display anything?
Is this line the one causing the blank screen: $cheeses = array_chunk($cheeses); Or is it a different line? If you are able to get a count value then it sounds like it's an array value that could call array_chunk. Is the error further down?
Comments
$cheeses = fuel_model('cheeses'); $chunks = array_chunk($cheeses);
For some reason it doesn't work:
$cheeses = array_chunk($cheeses);
gives me blank screen.
Even if I try: print_r($cheeses) I get blank screen.
If I try this:
$x[0] = array('name'=>'Bob', 'age'=>10);
$x[1] = array('name'=>'Brad', 'age'=>20);
$x[2] = array('name'=>'Gill', 'age'=>30);
$x[3] = array('name'=>'Steve', 'age'=>40);
$x = array_chunk($x, 3);
print_r($x);
It works, but with print_r($cheeses) or even var_dump($cheeses), I get blank screen.
foreach on $cheeses, works though.
echo count($cheeses);
display anything?$cheeses = array_chunk($cheeses);
Or is it a different line? If you are able to get a count value then it sounds like it's an array value that could call array_chunk. Is the error further down?
This is what I tried:
$x = array_chunk($cheeses, 3);
1.
foreach($x as $y) {
echo $y->cheese_name;
}
I get this error on the echo line:
Message: Trying to get property of non-object
2.
foreach($x as $y) {
print_r($y);
}
I get a white page.
3.
print_r($x);
I get a white page.