jeudi 28 juin 2018

check the array value is set or nor

I'm fetching practice_string_id and program_string_id from a table

$project_type = DB::table('project')
              ->where('code',$asset_request->project_code)
              ->select('practice_string_id','program_string_id')
              ->first();
print_r($project_type); //output 
   stdClass Object ( [practice_string_id] => PRACTICE0028 [program_string_id] => )   

I want to check $project_type->program is set or not in if condition

if(isset($project_type->program_string_id)){
   //nothing in $project_type->program but reached here now 
 }

I want to how to check the value is set or not in php if condition



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire