Skip to content
Advertisement

Include variable into array if not empty inside foreach

Include the name variable if the value is not empty inside the foreach. I tried this method code below but it include outside the array. I want to include within the array.

Sample Code:

JavaScript

Output code above:

JavaScript

The output should be like this:

JavaScript

The shift_start and shift_end should be within the array not outside. My code is working in 1 array only and not on the foreach. However, it doesn’t working within for each.

Advertisement

Answer

You need to add shift_start and shift_end values into the data array before you push it into $load_array. Something like this:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement