php - how to check if values inside array is present codeigniter -


hi how can check values of array if present? example have table

------------------ id | key | group | ------------------ 1  | abc |   1   | ------------------ 2  | def |   1   | ------------------ 3  | abc |   2   | ------------------ 

so can see value 2 doesnt have def key. if query

select * thistable group = 2. 

it give array(id = > 1 key => abc group = 2)

how check value of array instance

if(this array have key abc){  execute code}  if(this array have key def){  execute code} 

you need use in_array() required result like:

basic example:

<? $testarr = array('id' => 1,                    'key' => 'abc',                   'group' => 2);  if(in_array('abc', $testarr)){   echo "success";   } else{   echo "failed";   } ?> 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -