Here it's my sample of code :
public function show($imei,$start_time,$end_time,$dateto) {
$from_time = str_replace('-','/',$start_time);
$fromi=strtotime($from_time . ' ' . $end_time);
$too1=strtotime($from_time . ' ' . $dateto);
$data['coordinates'] = $this->road_model->get_coordinatesudhetime($imei, $fromi, $too1);
$this->load->view('road/show', $data);
if (!empty($data))
{
echo 'Array it's empty*';
}
}
I want to check when $data it's empty .
if (empty($data))
{
echo "array is empty";
}
else
{
echo "not empty";
}
or count($data) returns the size of array.
If you are not sure about the variable being an array, you can check type and then size.
if(is_array($data) && count($data)>0)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With