I have a php code like this
$output .= '<div>';
$output .= sprintf('<input type="text" name="%s"/>', $field['input_name']);
$output .= '</div>';
return $output;
These input fields can be duplicated. So $field['input_name'] is a multidimensional array
So it looks like this
name[first_name][1][1]
If I duplicate that field it looks like this
name[first_name][2][1]
I would like to display a button if the name field looks like name[username][][]
I’ve tried like this. But its not working.
if ($field['input_name'] == 'name[username][][]') {
$output .= '<input type="submit" value="Testing">';
}
Can someone give me the correct syntax?
Thanks
You need to implement a
foreach()loop or some function, that searches your array. Your best friend in this case is RecursiveIteratorIterator.Implementation (example):
If you handle with with big data arrays, this solution might be slow.