How to check two result arrays in codeigniter view?

by scotty_walker , in category: PHP Frameworks , 7 months ago

How to check two result arrays in codeigniter view?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by mac , 7 months ago

@scotty_walker 

You can check two result arrays in CodeIgniter view by using PHP code to loop through each array and compare their elements. Here is an example of how you can check and compare two result arrays in a CodeIgniter view:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<?php
foreach($result_array1 as $item1) {
    foreach($result_array2 as $item2) {
        if($item1['id'] == $item2['id']) {
            // If the IDs match, do something
            echo "ID Matched: " . $item1['id'] . "<br>";
        }
    }
}
?>


In this example, we are looping through each item in both result arrays ($result_array1 and $result_array2) and checking if the ID of the items match. If the IDs match, we are echoing out a message indicating that the IDs matched.


You can modify this code based on the structure of your result arrays and the specific elements you want to compare.