mysql - php complex assoc array match with $_POST -
i have array
array('0284'=>array('name'='xx', 'inputs'=array( array('sysname'=>'key_to_match1',....); array('sysname'=>'key_to_match2',....); ), '0287'=>array('name'='yyy', 'inputs'=array( array('sysname'=>'key_to_match3',....); array('sysname'=>'key_to_match4',....); ) );
what want search $_post if key sysname exist homecoming array 'name'..
example if $_post['key_to_match1'] exist homecoming xx
edit
array construction explanation:
array result of fetching db table
plugins(id,name,user_id) plugins_inputs(id,plugin_id(fk),sysname,label,value,extra_attrs)
what fetch plugins , inputs, separate them pluigns_id
array('plugins.id'=>array('name'='plugins.name', 'inputs'=array(//all rows plugins_inputs plugin_id=plugins.id array('sysname'=>'key_to_match1',....); array('sysname'=>'key_to_match2',....); )
plugins.id key: avoid duplicates cann't trust form.name
plugins.name : points function name handles these inputs
plugins_inputs : contain multiple rows of inputs
now want hear $_post case of these inputs submited redirect form specific function handle it. $this->${plugins.name}->backend();
currently using
foreach($array $id=>$val){ foreach($val['inputs'] $input) //$this->input->post codeigniter help handle $_post[] if doesnt exist homecoming false if($this->input->post([$input['sysname']])runbackend($val['name'],$id); }
but wondering if there smarter way it.. using array_filter or array_map or something... }
try 1 ...
foreach($data $key => $d) { foreach($d $key => $dat) { if(in_array("$_post['key_to_match1']",$dat['inputs']) { echo $d['name']; } else { echo "not found"; } } }
php mysql multidimensional-array
No comments:
Post a Comment