How to print associative array in codeigniter?

Member

by samara , in category: PHP Frameworks , 4 months ago

How to print associative array in codeigniter?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by hal.littel , 4 months ago

@samara 

In CodeIgniter, you can print an associative array using the print_r() function.


Here's an example:

1
2
3
4
5
6
7
8
9
$data = array(
    'name' => 'John Doe',
    'age' => 30,
    'email' => '[email protected]'
);

echo '<pre>';
print_r($data);
echo '</pre>';


This code will output the associative array in a formatted way, making it easier to read. You can include this code in your controller or view file in CodeIgniter to print the associative array.