React element mapping equivalent on CodeIgniter

So let say I have this html element:


And also this array of object:

var obj = 
    "name": "Luke",
    "number": "101",
    "name": "Mike",
    "number": "102",

I want to map the array value and put it on html element. In react I usually do it like this:


The result will be:



Now I want to do it on CodeIgniter but I couldn’t find the equivalent way. Maybe someone can help me to solve this or give reference. Thanks!


You can do it like this:

<?php foreach($obj as $name => $number){ ?>
   <p><?php echo $name ?></p>
   <p><?php echo $number ?></p>
<?php } ?>

Leave a Reply

Your email address will not be published. Required fields are marked *