[FX.php List] Current function

Anders Monsen andersm at alamark.com
Thu Nov 13 12:58:19 MST 2008


Hi Joel,

I think I see what you mean. So, it would be something like this  
instead, perhaps?

foreach($resultAcct['data'] as $key=>$current);
	$recordDetails = explode('.',$key);
	$recid = current($recordDetails);
	$nameFirst	= $current['Name_first'];

Either way it does seem like I use about the same amount of code in  
any of the options. I might be confusing the issue for myself by using  
the current function and naming a variable $current.

I've always wondered what the  [41.6] => Array referred to, so thank  
you clarifying this. It now make a heck of a lot more sense how we're  
able to get the $recid, $modid in the list() function, and why the  
above piece works. Previously I was just looking for something that  
worked; now I have a much better understanding of WHY it works.

Anders

On Nov 13, 2008, at 1:34 PM, Joel Shapiro wrote:

> Hi Anders
>
> Here's my understanding:
>
>
> If you wanted to use the current() function, you could use:
>
> current( $recordDetails )  *instead of*  $recordDetails[0]
>
> but that doesn't really save you anything, and either way, you still  
> need to use explode() to capture the recid...
>
>
> If you ever display the returned 'data' array in FX.php  
> ($createResult['data']), you'll see that it looks like:
>
> Array
> (
>    [41.6] => Array
>        (
>            [NameFirst] => Array
>                (
>                    [0] => Anders
>                )
>            [NameLast] => Array
>                (
>                    [0] => Monsen
>                )
>        )
> )
>
> You'll notice that the first (and only) element of this array has a  
> key of "41.6".  That represents FileMaker's internal Record ID and  
> Modification ID (i.e. the number of times that record has been  
> modified), so in my example, your record has recid 41 and has been  
> modified 6 times.
>
> In your foreach loop example (below), the explode() function is used  
> to separate the values on either side of the period into separate  
> values of a new $recordDetails array:
>
> Array
> (
>    [0] => 41
>    [1] => 6
> )
>
> Then to get the record id, you can use either current() or [0].
>
>
> NOTE: I'm not sure how list() is preferable to creating an array.   
> GGT or Steve care to comment?
>
>
> HTH,
> -Joel
>
>
>
> On Nov 13, 2008, at 9:26 AM, Anders Monsen wrote:
>
>> Revisiting this function, is it possible to get the FileMaker  
>> record ID via current( )? I use this to pull fields from a found  
>> set of one, and I need to send over the recid in a form.
>>
>> Until now I have been using something like this:
>>
>> foreach($createResult['data'] as $key=>$value) {
>> 	$recordDetails = explode('.',$key);
>> 	$currentRecord = $recordDetails[0];
>> }
>>
>> While I like the elegance of current( ), I am not sure how to  
>> isolate the recid piece, which would be very useful.
>>
>> Thanks,
>> Anders
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>



More information about the FX.php_List mailing list