I have a php multidimensional array which looks like this:
$fields = array( array('input', 'title', 'slug', 'keywords'),
array('textarea', 'content'),
array('radio', 'active', 'active2', 'active3', 'active4', 'active5')
);
and I am accessing the array, like this.
However because some arrays contain more values than others I am having trouble, as you can see below $type < 2…how do I fix this?
for($type = 0; $type < 2; $type++) {
for($field = 0; $field < 2; $field++) {
echo $fields[$type][$field];
}
}
Use a
foreach: