0

how can we check the indexes of an array in if statement and if it is not available than skip or else perform something. i am using in array function but it is not working and throws an error of undefined offset.

<!DOCTYPE html>
<html>
<head>
    <title>csv view</title>
</head>
<body>
    <table>
        <thead>
            <?php
                $num_of_rows = count($missing_record_data);
                $num_of_columns = count($missing_record_data[$index]);

                for($i=0; $i<=$num_of_columns-1; $i++): 
            ?>
                    <th><?= $column_names[$i]; ?></th>
            <?php endfor; ?>
        </thead>
        <tbody>
            <?php for($i=0; $i<=$num_of_rows-1; $i++): ?>
                <?php
                    if(in_array($missing_record_data[$i+1],$missing_record_data)):
                ?>
                <tr>
                    <?php for($j=0; $j<=$num_of_columns-1; $j++): ?>
                        <td><?= $missing_record_data[$i+1][$j]; ?></td>
                    <?php endfor; ?>
                </tr>
                <?php
                    endif;
                    endfor;
                ?>
        </tbody>
    </table>
    <h1><strong>Note:</strong>These rows were not imported because the blank fields are required. Rest has been uploaded successfully.</h1>
</body>
</html>

this is the error:

Severity: Notice

Message: Undefined offset: 1

Filename: views/uploaded_csv_view.php

Line Number: 21
Abdal Asif
  • 47
  • 13

0 Answers0