Home »
Imported messages »
comp.lang.php »
Problem: Read array of array into flat array
Re: Problem: Read array of array into flat array [message #170872 is a reply to message #170871] |
Sat, 04 December 2010 12:23 |
gina
Messages: 2 Registered: December 2010
Karma:
|
Junior Member |
|
|
Hallo Micha.
Vielen lieben Dank ... manchmal steh ich einfach aufm Schlauch!!!
Gruß Gina :)
"Michael Fesser" <netizen(at)gmx(dot)de> schrieb im Newsbeitrag
news:67ckf6tt72h3b0vis6vm8v4k4b1fe1b8d8(at)mfesser(dot)de...
> .oO(gina)
>
>> I am having a problem with that array and I don't seem to get my head
>> round
>> so thought I better ask for some good help ;)
>>
>>
>> ...
>> foreach ($detailsArray as $details) {
>> $counter++;
>> foreach ($details as $key => $value) {
>>
>> $arrayData[] = array(
>> 'id'.$counter => $value->getId(),
>> 'detail'.$counter => $value->getDetailText()
>> );
>> }
>>
>>
>>
>> rather than an array of array I'd like to have an array containing the
>> values all in a flat form
>>
>> the function should return an array like:
>>
>> $resultArray = array('id1' =>'1', detail1 => 'ABC', id2 =>'1', detail2 =>
>> 'DEF');
>>
>>
>> How am I going to achieve this ?
>
> foreach (…) {
> $arrayData['id'.$counter] = $value->getId();
> $arrayData['detail'.$counter] = $value->getDetailText();
> }
>
> Micha
|
|
|
Goto Forum:
Current Time: Mon Nov 25 20:26:01 GMT 2024
Total time taken to generate the page: 0.05699 seconds