I'm trying to create a new set of arrays from an existing array, using the code:
var stock = new Array()
for (i = 0; i < seOutput.length; i++) {
stock[i] = new Array(seOutput[i][0], seOutput[i][1], seOutput[i][2], seOutput[i][3], seOutput[i][4])
}
If I console.log(seOutput); I see this:
Array
(
[0] => Array
(
[0] => Blue
[1] => Yes
[2] => No
[3] => Yes
[4] => Yes
)
[1] => Array
(
[0] => Red
[1] => No
[2] => No
[3] => No
[4] => Yes
)
This worked logically in my head, where the code seOutput[0][0] would equal Blue, but that's not what's given back in my console.log(seOutput[0][0] statement. For the statements console.log(seOutput[0]) and console.log(seOutput[0][0]) I get A (the first letter in the word Array ).
What is the proper way to access this array?
To give a bit more detail, seOutput is generated from my ajax success call to a .php page where the final bit of code is:
foreach ($json['Result']['Data']['Type'] as $i) {
$y = "{$i['Color']},{$i['Object']},{$i['Crs']},{$i['CrsX']},{$i['CrsB']}";
$x = explode("," , $y);
array_push($output, $x);
}
then
print_r($output);
and my ajax code:
$.ajax({
url: "seSearch.php",
type: "post",
data: {partNumber: q , c:c},
success: function(data) {
var seOutput = data;
}
});
What's generated from that is the "array" I pasted above. Why ajax has converted this into a string I don't know....
seOutputorstock?stockis built fromseOutput, and theforloop works, it just doesn't populates with bogus data because I'm not referencingseOutputcorrectly.