How to check two result arrays in codeigniter view?

by scotty_walker , in category: PHP Frameworks , a year ago

How to check two result arrays in codeigniter view?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by mac , a year 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.

Related Threads:

How to pass two arrays to view in codeigniter?
How to use model function result in controller by codeigniter?
How to check the key of next index of arrays in php?
How to merge multiple arrays in codeigniter?
How to check undelivered email with smtp in codeigniter?
How to check view size in teradata?