[FX.php List] Filling a multi-dimensional array
Jonathan Schwartz
jschwartz at exit445.com
Tue Sep 9 13:03:57 MDT 2008
Hey Steve!
This is actually the next step of the technique you gave me during
lunch at DevCon. ;-)
I am adding the ability to process additional search parameter pairs
in my favorite searchPage template script. There might be 0 extra
parameter pairs...there might be 5. So... they will not always be
just "year" and "status".
How do I deal with that?
On the other end, in building the FMP query that uses these pairs,
this the script I use to create the addlitional AddDBParam entries;
foreach($additionalParameters as $paramKey => $paramValue)
{
$search->AddDBParam($paramKey, $paramValue);
}
I suspect that the multidimensional array will not work with the code above.
J
At 7:37 PM +0100 9/9/08, Steve Winter wrote:
>Hi Jonathan,
>
>Try this;
>
> $counter = 0;
> $additionalParameters= array();
> foreach($findResult2['data'] as $key => $value2) {
> $additionalParameters[$counter]['year'] = $value2['paramkey'][0];
> $additionalParameters[$counter]['status'] = $value2['paramvalue'][0]);
> $counter++;
> }
>
>
>Should give you;
>
>Array (
> [0] => Array (
> [year] => 2008
> [status] => active
>
>)
>)
>
>Cheers
>Steve
>
>-----Original Message-----
>From: Jonathan Schwartz <jschwartz at exit445.com>
>To: "FX.php Discussion List" <fx.php_list at mail.iviking.org>
>Date: Tue, 9 Sep 2008 11:16:45 -0700
>Subject: Re: [FX.php List] Filling a multi-dimensional array
>
>Thanks DC.
>
>Although this does build an array with each record, it isn't the
>type of array structure I was expecting .
>
>I was looking for this result:
>
>Array
>(
> [year] => 2008
> [status] => active
>)
>
>I got this result:
>
>Array
>(
> [0] => Array
> (
> [status] => active
> )
>
> [1] => Array
> (
> [year] => 2008
> )
>)
>
>
>Jonathan
>
>
>
>At 1:32 PM -0400 9/9/08, DC wrote:
>
>
>>$additionalParameters[]= array($value2['paramkey'][0] =>
>>$value2['paramvalue'][0]);
>>
>>Jonathan Schwartz wrote:
>>
>>>Apologies ahead of time for asking this RTM question, but I need
>>>to get this worked at ASAP.
>>>
>>>I need to populate a multi-dimenisional array from an FMP query.
>>>The existing code, below, populates only the last record. What
>>>syntax build the array with all found values?
>>>
>>>
>>>$additionalParameters= array();
>>> foreach($findResult2['data'] as $key => $value2)
>>> {
>>> $additionalParameters= array($value2['paramkey'][0] =>
>>>$value2['paramvalue'][0]);
>>> }
>>>
>>>
>>>Thanks
>>>
>>>J
>>>
>_______________________________________________
>FX.php_List mailing list
>FX.php_List at mail.iviking.org
>http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
>
>--
>Jonathan Schwartz
>Exit 445 Group
>jonathan at exit445.com
>http://www.exit445.com
>415-370-5011
>
>
>_______________________________________________
>FX.php_List mailing list
>FX.php_List at mail.iviking.org
>http://www.iviking.org/mailman/listinfo/fx.php_list
--
Jonathan Schwartz
Exit 445 Group
jonathan at exit445.com
http://www.exit445.com
415-370-5011
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20080909/e4c56331/attachment.html
More information about the FX.php_List
mailing list