I have a requirement to accept an array of checked items from a table and update the field based on which items were selected. At first, I thought about where to simply scroll through each of these elements in an array and access a function in a particular class to update the state.
I'm a little worried about this approach, as that would mean creating an instance of the object for each iteration of the loop to update the corresponding status.
foreach($example as $exampleId){
$newExample=new Example($exampleId);
$newExample->updateStatus('active');
}
Are there any better ways? This seems like bad practice, but I'm struggling to find an alternative way.
user275074
source
share