used php for a while but cannot get what is going on here! I've tried array_merge() and array_push() on an array to be able to add arrays to an array of existing arrays.
For example, to be able to add x and y into the same array using a loop:
$x = [x, y, z];
$y = [a, b, c];
$goal = [[x, y, z], [a,b,c]];
Feel like I am so dinged up on this problem I am missing something really obvious! I've tried all of the following but have had nothing work.
$intermediate = array([x,y,z];;
$goal = array($goal, $intermediate)
$goal[$i] = $intermediate;
$goal[$i][$j] = $raw[i][j]; // lets say raw is where elements come from
From what I have seen this is an indexed array that is multidimensional but I am completely stuck as I have been working it for hours! Any help appreciated!
[EDIT] Essentially I am trying to push into Google sheets and it accepts input of the form [[$val1], [$val2]] for an insertion for two columns and of the form [[$val1, $val2]] for an insertion into a row.
I have a 2d array, where each array will be a separate row but it doesn't seem to be working. I am updating $goal to $goal = [$goal, $intermediates] but it doesn't seem to work - it only keeps the first line.
My goal is to push content of the form [[$val1,$val2],[$val3,$val4]] but it only inserts the [$val1,$val2] part.
$goal = [];
for ($i = 0; $i < count( $info) ; $i++){
$value1 = $info[$i][0]; // fname
$value2 = $info[$i][1]; // lname
$value3 = $info[$i][2]; // age
$person =[$value1, $value2, $value3];
$goal = [$goal, $person];
}
I have also tried with the array() version rather than the square brackets.
$goal = [$x, $y];? Please provide an actual example of input/output, as I'm unsure what that second snippet is trying to achieve.