By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP Undefined Array Key Help


Active Coder
Hi, I am getting a PHP Warning of undefined array key on the following line. Wondering how I can adjust this function to get the warning to go away?

            $rows[$key] = $row['id'];

which is inside the following function

function getWorkingPapers() {
    if(get_field('working-papers', 33)) {
        $paperCounter = 0;
        $rows = get_field('working-papers', 33);
        $rowCount = count($rows);
        $workingPapers = '<ul class="download-list">';
        $paperArray = array();
        foreach($rows as $key => $row) {
            $rows[$key] = $row['id'];
            $paperArray[$key]['title'] = $row['title'];
            $paperArray[$key]['author'] = $row['author'];
            $paperArray[$key]['file'] = $row['file'];

        $rowCount = count($rows); $paperNO = $rowCount;
        for ($i = ($rowCount - 1); $i >= 0; $i--) {
            if ($paperCounter <= 2) {
                $workingPapers .= '<li>';
                $workingPapers .= '<a target="_blank" href="'.$paperArray[$i]['file'].'">';
                $workingPapers .= '<b class="number">'.$paperNO--.'.</b>';
                $workingPapers .= '<p>“'.$paperArray[$i]['title'].'”</p>';
                $workingPapers .= '<strong class="name">'.$paperArray[$i]['author'].'</strong>';
                $workingPapers .= '</a>';
                $workingPapers .= '</li>';
        $workingPapers .= '</ul>';
    return $workingPapers;

New Threads

Latest posts

Buy us a coffee!

Top Bottom