Jump to content

if statements


petroz

Recommended Posts

Hey Guys,

 

I am creating an array and I have a need to put a if statement inside it. Is this even possible?

 

Here is where I am at so far, its just not working.


function load_permissions($gid)
    {
    	$data = array();
    	$this->db->select('`groups`.`name` AS `permission_name`, `permissions`.``');
	$query = $this->db->get('`groups`,`permissions`');
	if ($query->num_rows() > 0){
		foreach ($query->result_array() as $row){
	 		$data[] = array(
	 			"name" => $row['permission_name'],
	 			"read" => if($row['level'] >= 1)
	 			 { 
	 			 	img("img/true.gif")
	 			 } else { 
	 			 	img("img/false.gif")
	 			 },

	 		);
	 	}
	 }

	 $query->free_result();
	return $data;

 

Thanks,

Peter

 

Link to comment
https://forums.phpfreaks.com/topic/217523-if-statements/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.