I am working with php and call a php function with ajax:
<button onclick="loop()">Do It</button>
function loop() {
$.get("ajax.php", {
action: "true"
},
function(result) {
$("input").val(result);
});
}
PHP
if (isset($_GET["action"])) {
for ($i = 0; $i < 5; $i++) {
$array[] = array( "Value 1", $i );
}
echo $array;
}
My Input value will show this:
Now I would like to show the first array element. I modify the code like this:
$("input").val(result[0][0]);
My result:
But it has to be "Value 1"
Here is an overview of my array structure:
Array
(
[0] => Array
(
[0] => Value 1
[1] => 0
)
[1] => Array
(
[0] => Value 1
[1] => 1
)
[2] => Array
(
[0] => Value 1
[1] => 2
)
[3] => Array
(
[0] => Value 1
[1] => 3
)
[4] => Array
(
[0] => Value 1
[1] => 4
)
)