Questions tagged [array-push]

array-push refers to the javascript Array.prototype.push() method. The push() method adds one or more elements to the end of an array and returns the new length of the array.

refers to the javascript Array.prototype.push() method.

The push() method adds one or more elements to the end of an array and returns the new length of that array. developer

Example

var a = []; //or new Array()
var i = a.push('foo', 'bar');
console.log(i, a); 

the console will display the values

2 ["foo", "bar"]

The counterpart to push() is pop(), which removes the last item from an array.

Documentation

382 questions
-2
votes
1 answer

syntax error, unexpected T_DOUBLE_ARROW

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
-3
votes
1 answer

Javascript Array.push creating a nested array which I cannot access using the index

I have looked at the following articles, which all go into depth about asynchronous calls return undefined. Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference Get data from fs.readFile This doesn't…
IndustryDesigns
  • 1,938
  • 2
  • 12
  • 22
-3
votes
1 answer

Error in Validating Login Form details in PHP

Following is the code function addValidation($variable,$validator,$error) { $validator_obj = new ValidatorObj(); $validator_obj->variable_name = $variable; $validator_obj->validator_string = $validator; …
-3
votes
2 answers

PHP Array issue (beginner)

I'm receiving an integer value from my array, instead of a name. How can i correct my code to randomly select a name from the array? $family = array(); array_push($family, "joe"); array_push($family, "bill"); …
DevEarl
  • 18
  • 1
  • 3
-3
votes
2 answers

array_push is couting the value instead of adding

When I insert the value to the array its counting the value instaed of adding. I have the below array named $staff_group_arr Array ( [0] => All Rights User [1] => Operation [2] => Supritendent [3] => Admin Department [4] => Accounts [5] =>…
user3300202
  • 7
  • 1
  • 5
-3
votes
2 answers

PHP add key => value to each array in array

Best shown in practice, I have 2-dimensional array like this: array(3) { [0]=> array(2) { ["id"]=> string(4) "3229" ["name"]=> string(0) "foo" } [1]=> array(2) { ["id"]=> string(4) "2588" ["name"]=>…
kajacx
  • 12,361
  • 5
  • 43
  • 70
-4
votes
3 answers

PHP - Looking for a way to compare a value in two dimensional array, then combine arrays with same value to form a three dimensional array

am looking for a way to achieve result of the above title. I have a two dimensional array like this Array ( [0] => Array ( [reference_no] => A0012 [code] => HSWH30 [net_unit_price] => 24000 …
Gifto
  • 21
  • 1
  • 2
  • 9
1 2 3
25
26