I am passing array data to my view like this
public function login(){
$array= array(
array(
'type' => 'text',
'usrname' => 'username',
'class' => 'form-control',
'placeholder' => 'Username',
),
array(
'type' => 'password',
'class' => 'form-control',
'placeholder' => 'Password',
),
array(
'type' =>'heading',
'heading' =>'Not a Memer YET ?',
),
);
$output['data']=$array;
$this->load->view('authentication',$output);
in my view this is what i'm doing
<?php foreach ($data as $key=> $value):?>
<?php
switch ($value){
case $value['type']=='heading':
echo $value['heading'];
break;
case $value['type']=='text':
echo 'textfield';
break;
}
?>
<?php endforeach;?>
this is working properly but i just want to ask is it standard practice the way i am doing it or there can be any better way to traverse this array in switch .
Need your help please
This question is not about if i should use switch or if else , i want to know the way I've used switch in terms of coding is it correct or not ?or i can improve it .