How do i add more data into this array?
I am not very familiar with this type of array. How do i push another set of data in this type of array?
$array = arra开发者_StackOverflow中文版y(
array(
'service_name' => $row['application_name'],
'html_id' => $row['html_id'],
'url' => $row['url']
)
);
as far as I understood-
$array[]= array(
'service_name' => $row['application_name'],
'html_id' => $row['html_id'],
'url' => $row['url']
);
will add another section, same as first
This adds another array to the outhermost array:
$array[] = array('key' => 'value', 'key2' => 'value2');
Always take the path of the PHP man my friend :) http://php.net/manual/en/function.array-push.php
it depends on which array you want to put data into :) - the first one is a classical array and the included one is an associative array
The answer really depends on what the application or API is expecting but to take a wild stab at it, something like -
<?php
$array = array (
array (
'service_name' => $row['application_name'],
'html_id' => $row['html_id'],
'url' => $row['url']
),
array (
'service_name' => 'app2',
'html_id' => 'htmlid2',
'url' => 'url2'
)
);
精彩评论