[FX.php List] FMPHP API

AC ac at pottnerconsulting.ca
Tue Aug 1 12:54:58 MDT 2006


Not meaning to beat a dead horse here;
- you said the equivalent of the FileMaker "Left()" function is the PHP 
"substr()" function
- you also said the PHP "strcspn()" function is not a common function 
to use
- I'm currently using    substr(Text, 0, strcspn(Text, " "))
- what function should I be using inside "substr()" instead of the 
"strcspn()" function?  (I'm completely new to PHP so I assume I'm just 
missing the obvious answer)



On Jul 31, 2006, at 11:41 AM, DC wrote:

> well, strcspn() is another obscure function. i've been coding PHP on a 
> daily basis for several years now and i had to look it up! it may have 
> a specialized usage and you've certainly demonstrated one interesting 
> one ;-) it took me a minute to wrap my head around that one.
>
> But, your best bet for code share-ability, maintainability and 
> readability is to know and explore the outer reaches of PHP functions 
> but when writing PHP to accomplish basic tasks, use standard PHP 
> idioms like list with explode. PHP offers multiple paths to the same 
> outcome but if you write code with idiosyncratic idioms you're going 
> to run into trouble down the road - with other PHP coders and with 
> your own memory.
>
> FYI, the equivalent to FMP's left() function in PHP is substr():
>
> http://us2.php.net/manual/en/function.substr.php
>
> Cheers and happy coding,
> dan
>
> On Jul 28, 2006, at 8:04 PM, AC wrote:
>
>> Thanks Andrew & Dan,
>>
>> I had found both strtok() and list() with explode().
>> I guess I'm still thinking in FileMaker terms when I'm doing things 
>> in PHP so I was looking for something like;
>> Left(Text, NumOfChar) and Replace(Text, Start, Size, ReplacementText)
>> I just figured since PHP had such an easy function to grab the 
>> remainder of the string (the equivalent of the FM Replace command) 
>> that it probably also had an easy equivalent of the FM Left command.
>> Based on your answers I'm guessing it doesn't and the    substr(Text, 
>> 0, strcspn(Text, " "))    command is the closest equivalent.
>>
>>
>>
>>
>> On Jul 28, 2006, at 6:01 PM, DC wrote:
>>
>>> i would stay away from strtok()
>>>
>>> strtok() is a confusing function because it has an internal stack 
>>> that 'remembers' how many times you've called it and then you have 
>>> to call it the number of times that you have strings to split.
>>>
>>> much better and more widely used and standard is to use this 
>>> construction using list() and explode()
>>>
>>> $variable = "311 something";
>>> list($number,$word) = explode(' ',$variable);
>>>
>>> now you'll have two nicely named variables one that has the number 
>>> and one that has the word
>>>
>>> cheers,
>>> dan
>>>
>>> On Jul 28, 2006, at 3:59 PM, Andrew Denman wrote:
>>>
>>>> Don't know about your first question, but for the second one, it 
>>>> looks like
>>>> you want to break the string on the spaces.  Check out strtok():
>>>> http://us3.php.net/manual/en/function.strtok.php
>>>>
>>>> Andrew Denman
>>>>
>>>> -----Original Message-----
>>>> From: fx.php_list-bounces at mail.iviking.org
>>>> [mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of AC
>>>> Sent: Friday, July 28, 2006 2:51 PM
>>>> To: FX.php Discussion List
>>>> Subject: [FX.php List] FMPHP API
>>>>
>>>> Anyone know if this API will grab both value fields from value lists
>>>> that are based on 2 fields ex.
>>>> The "Company" value list uses the fields "IDCompany" and 
>>>> "CompanyName".
>>>> In FX only the IDCompany is returned.
>>>> Does this API return both values?
>>>>
>>>>
>>>>
>>>> Also, assuming I had   MyVariable = "316 Dell"
>>>> I can use the function    strstr(MyVariable, " ")
>>>> to get the "Dell" part by itself but to get the 316 I'm currently 
>>>> doing
>>>>    substr(MyVariable, 0, strcspn(MyVariable, " "))
>>>> Is there an easier way to get the 316 by itself (assuming it could 
>>>> also
>>>> be text)?
>>>>
>>>> _______________________________________________
>>>> FX.php_List mailing list
>>>> FX.php_List at mail.iviking.org
>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>>
>>>> _______________________________________________
>>>> FX.php_List mailing list
>>>> FX.php_List at mail.iviking.org
>>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>
>>> _______________________________________________
>>> FX.php_List mailing list
>>> FX.php_List at mail.iviking.org
>>> http://www.iviking.org/mailman/listinfo/fx.php_list
>>>
>>>
>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
> _______________________________________________
> 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