The code has several important errors:
- You can not have a
for
loop within the definition of a array
- It seems that you want to simulate a ternary operator, but you lack parts (specifically the most important one that would be the assignment)
- Operations in PHP are separated with a semicolon, and not with a comma or nothing.
To solve these problems you should:
- Define the variable
$product_min_qty
as an empty array
- Create a loop and fill in the variable within that loop
- The two parts of
if..else
are equal, you could simplify them directly or, if they are going to be different, use a ternary operator to define each part
- As indicated by Genarito in your comment , the condition of the
if
can be simplified because the second part ( $i+1>$tama
) will always be false for the values of the loop for
.
Something like this (I have not tried it and may contain errors):
$prodlang = $wpdb->get_results("SELECT * FROM wp_post WHERE wp_pedmin!=0");
$tama= count($prodlang);
$product_min_qty = array()
for($i=0;$i<$tama;$i++){
$product_min_qty[] = ($i+1 == $tama) ?
array( 'id' => $prodlang[$i]->ID , 'min' => $prodlang[$i]->wp_pedmin) :
array( 'id' => $prodlang[$i]->ID , 'min' => $prodlang[$i]->wp_pedmin);
}
As I put you in a comment that I deleted, I would recommend that while you are developing you use error_reporting(E_ALL);
at the beginning of the page to see what errors you have, because it would be of great help to identify and solve problems such as shared code.