FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Problem: Read array of array into flat array
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Problem: Read array of array into flat array [message #170871 is a reply to message #170868] Sat, 04 December 2010 12:17 Go to previous messageGo to previous message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma:
Senior Member
.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
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: comp.lang.php
Next Topic: Efficiency of a lot of variables
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Nov 22 18:12:31 GMT 2024

Total time taken to generate the page: 0.03891 seconds