SneakyDave
Well-known member
I'm trying to do some XML stuff with a web service, and I am obviously missing something here with creating an array structure.
Basically, I want to create an array with this structure through an iterative process, maybe I'm already doing this, but I thought I'd run by more sets of eyes.
So, an array of contacts that contains an array of names and numbers.
So I try something like this to accomplish that, although it appears to not be correct...
But then the result is this:
I understand why that happens, but is the result basically the same as what I want in the first code paragraph? In this case, the key/value pair is an integer and the array.
Maybe that's what I really want anyway, and I'm just not interpreting the structure like I should?
edited code tags to php tags
Basically, I want to create an array with this structure through an iterative process, maybe I'm already doing this, but I thought I'd run by more sets of eyes.
PHP:
Array ( [contacts] =>
Array ( [name] => David [number] => 1111111111 )
Array ( [name] => Tom [number] => 2222222222 )
)
So, an array of contacts that contains an array of names and numbers.
So I try something like this to accomplish that, although it appears to not be correct...
PHP:
$names= array();
array_push($names, array('name' => 'David', 'btn' => '1111111111'));
array_push($names, array('name' => 'Tom', 'btn' => '2222222222'));
$contacts= array('contacts' => $names);
But then the result is this:
PHP:
Array ( [contacts] =>
Array (
[0] => Array ( [name] => David [number] => 1111111111)
[1] => Array ( [name] => Tom [number] => 2222222222) )
)
I understand why that happens, but is the result basically the same as what I want in the first code paragraph? In this case, the key/value pair is an integer and the array.
Maybe that's what I really want anyway, and I'm just not interpreting the structure like I should?
edited code tags to php tags
Last edited: