Re: Parsing Strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Why not preg_split ( http://nz.php.net/manual/en/function.preg-split.php ):

$str = 'SCOTTSDALE, AZ 85254';
$ar = preg_split('/,? ?/', $str); //optional comma, followed by optional
space
// $ar = array('SCOTTSDALE', 'AZ', '85254');

On Sat, Dec 6, 2008 at 1:18 PM, Jason Todd Slack-Moehrle <
mailinglists@xxxxxxxxxxxxxxx> wrote:

>
> How might I also parse and address like: SCOTTSDALE, AZ 85254
>
> It has a comma and a space
>
> -Jason
>
>
> On Dec 5, 2008, at 4:02 PM, Jason Todd Slack-Moehrle wrote:
>
>  OK, making good learning progress today.
>>
>> I have a string that is: Jason Slack
>>
>> and I want it broken at the space so i get Jason and then Slack
>>
>> I am looking at parse_str, but I dont get how to do it with a space. The
>> example is using []=.
>>
>> Then I want to assign like:
>>
>> $fname = "Jason";
>> $lname = "Slack";
>>
>> Any ideas?
>>
>> -Jason
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux