How to reference different arrays in IF statement

I am looking for some basic PHP help with an IF statement.

The code below, says IF window is less than 1024, use the following table details for the arrays. There are two arrays at the bottom. However, I want to use different table details for each array.

So, I want to say ‘IF’ window is less than 1024 && it is array 1 below, use this code. Else, if it is array 2, use this other code.

I can’t figure out how to reference the different arrays. Any help appreciated.

<?php

/*Add Headers for responsive*/

$this->registerJs('$("document").ready(function () {
        var alterRTabelHeaders = function () {
            var resultCount = "' . $resultCount . '";
            var ww = document.body.clientWidth;
            if (resultCount > 0) {
                if (ww < 1024) {
                    $("table.fold-table  td:nth-of-type(1)").attr("data-before", "#");
                    $("table.fold-table  td:nth-of-type(2)").attr("data-before", "Action");
                    $("table.fold-table  td:nth-of-type(3)").attr("data-before", "Fields Changed");
                    $("table.fold-table  td:nth-of-type(4)").attr("data-before", "Action Date");
                    $("table.fold-table  td:nth-of-type(5)").attr("data-before", "By");
                }
            }
        };

        $(window).resize(function () {
            alterRTabelHeaders();
        });
        alterRTabelHeaders();
    });');

echo Tabs::widget([

    'items' => [
        array(
            'label' => 'Quotes (' . count($model->quotes) . ')',
            'content' => $this->render('quotes', ['dataProvider' => $dataProvider]),
        ),
        array(
            'label' => 'Changelog (' . count($model->feeds) . ')',
            'content' => $this->render('feeds', ['feedDataProvider' => $feedDataProvider, 'feedSearch' => $feedSearch]),
        )
    ],
    'options' => array(
       'class' => 'tabbable tabs-left ui-tabs-vertical ui-helper-clearfix ui-tabs-vertical'
    )
]);
?>

This is JavaScript (and not PHP). The JavaScript code gets passed (via PHP) to the browser to be executed. You may want to look at JavaScript resources to get this to work. I am no expert, or I will help you more.

@ snathan is right, that is javascript. But I noticed that your code is not saying what you are saying in plain English. The code says:
“In case there’s one result or more and window’s size is 1023 or less, then set this text to the ‘data before’ columns”
So some improvements I suggest:

  • What happens when the window is bigger than that? (Probably, you are missing an else)
  • Your question is about the “arrays” (do you mean the data?) but your code is about the “table”, so either the question is wrong or the code is wrong or your explanation is incomplete.