how can i rid of this error
Parse error: syntax error, unexpected T_DOUBLE_ARROW
PHP code:
$uniqueOrderCodes = array();
foreach ($checks as $check)
{
array_push($uniqueOrderCodes,"string" => $check);
}
thanx alot
how can i rid of this error
Parse error: syntax error, unexpected T_DOUBLE_ARROW
PHP code:
$uniqueOrderCodes = array();
foreach ($checks as $check)
{
array_push($uniqueOrderCodes,"string" => $check);
}
thanx alot
No offense intended, but you should read the manual. =>
it is an assignment operator and is used in arrays.
In the example $my_array = array('color' => 'blue')
, color
is the key, blue
is the value (of type string
) and $my_array
is the variable holding the array. In a nerdy language, that could sound like "Variable $my_array
is holding an array in which I assigned a string blue
to key color
; I can access that by using $my_array['color']
which will output blue
."
You push to arrays like this:
array_push($my_array, $var);
$var
it can be of a mixed
(mixed = any) type like string
, int
, array
, etc.
However, for just one element, you do not need to push
in array. Alternative:
foreach ($checks as $check)
{
$uniqueOrderCodes[] = $check;
}
See: