Re: [PHP] split() function

2001-07-04 Thread Steve Edberg

You don't need a character class here (signified by [] brackets); you can use

$line = split('&|//', $field);

As you can see, this is identical to ReDucTor's solution, except that 
the brackets are omitted. Character classes only work for single 
characters, not multiple character strings like '//'.

- steve


At 3:21 PM -0400 7/4/01, David A Dickson wrote:
>Thanks for replying ReDucTor but that didn't work either. I tried
>$line = explode("[(&|//)]", $field); and
>$line = explode("[(&|)]", $field); and
>$line = explode("[(&|\/\/)]", $field);
>with no success. Any other ideas?
>
>On Thu, 5 Jul 2001 04:50:29  
>  ReDucTor wrote:
>>$line = explode("[(&|//)]",$field); should work, or you might have to put
>> but thats not \ so you shouldn't need to comment out the slash...
>>- Original Message -----
>>From: David A Dickson <[EMAIL PROTECTED]>
>>To: php-general <[EMAIL PROTECTED]>
>>Sent: Thursday, July 05, 2001 4:37 AM
>>Subject: [PHP] split() function
>>
>>
>>>  I have a comma separated spreadsheet with one field that contains two
>>dates. the dates are formatted as dd/mm/yy and separated by either '&' or
>>'//' ex:3/12/92&28/1/93 or 3/12/92//28/1/93
>>>  Problem: I need to split the field at the '&' or '//' separator but if I
>>do
>  >> split('[&//]', $field);
>>>  it splits on the '/' not the '//'.
>>>  Can I do this in one function call to split() or will I have to do it
>>twice?
>
>
>
>Get 250 color business cards for FREE!
>http://businesscards.lycos.com/vp/fastpath/
>
>- End Forwarded Message -

-- 
+-- Factoid: Of the 100 largest economies in the world, 51 are --+
| Steve Edberg   University of California, Davis |
| [EMAIL PROTECTED]   Computer Consultant |
| http://aesric.ucdavis.edu/  http://pgfsun.ucdavis.edu/ |
+--- corporations -- http://www.ips-dc.org/reports/top200text.htm ---+

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] split() function

2001-07-04 Thread David A Dickson

Thanks that helped, this is what I used:
if (ereg("&", $field)) $line = explode("&", $field);
else $line = explode("//", $field);

On Thu, 5 Jul 2001 05:29:11   
 ReDucTor wrote:
>$line2 = explode("", $field);
>for($i = 0; $i < sizeof($line2); $i++){
>   if($line2[$i] == "&")
>  $useand = 1;
>   else if($line[$i + 1] == "/"){
>  if($line[$i] == "/"){
>$useslash = 1;
>  }
>   }
>}
>if($useand == 1)
>$line = explode("&", $field);
>if($useslash == 1)
>$line = explode("//", $field);
>?>



Get 250 color business cards for FREE!
http://businesscards.lycos.com/vp/fastpath/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] split() function

2001-07-04 Thread David A Dickson

Thanks for replying ReDucTor but that didn't work either. I tried
$line = explode("[(&|//)]", $field); and
$line = explode("[(&|)]", $field); and
$line = explode("[(&|\/\/)]", $field);
with no success. Any other ideas?

On Thu, 5 Jul 2001 04:50:29   
 ReDucTor wrote:
>$line = explode("[(&|//)]",$field); should work, or you might have to put
> but thats not \ so you shouldn't need to comment out the slash...
>- Original Message -
>From: David A Dickson <[EMAIL PROTECTED]>
>To: php-general <[EMAIL PROTECTED]>
>Sent: Thursday, July 05, 2001 4:37 AM
>Subject: [PHP] split() function
>
>
>> I have a comma separated spreadsheet with one field that contains two
>dates. the dates are formatted as dd/mm/yy and separated by either '&' or
>'//' ex:3/12/92&28/1/93 or 3/12/92//28/1/93
>> Problem: I need to split the field at the '&' or '//' separator but if I
>do
>> split('[&//]', $field);
>> it splits on the '/' not the '//'.
>> Can I do this in one function call to split() or will I have to do it
>twice?



Get 250 color business cards for FREE!
http://businesscards.lycos.com/vp/fastpath/

- End Forwarded Message -



Get 250 color business cards for FREE!
http://businesscards.lycos.com/vp/fastpath/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] split() function

2001-07-04 Thread ReDucTor

$line = explode("[(&|//)]",$field); should work, or you might have to put
 but thats not \ so you shouldn't need to comment out the slash...
- Original Message -
From: David A Dickson <[EMAIL PROTECTED]>
To: php-general <[EMAIL PROTECTED]>
Sent: Thursday, July 05, 2001 4:37 AM
Subject: [PHP] split() function


> I have a comma separated spreadsheet with one field that contains two
dates. the dates are formatted as dd/mm/yy and separated by either '&' or
'//' ex:3/12/92&28/1/93 or 3/12/92//28/1/93
> Problem: I need to split the field at the '&' or '//' separator but if I
do
> split('[&//]', $field);
> it splits on the '/' not the '//'.
> Can I do this in one function call to split() or will I have to do it
twice?
> ---
> : David A. Dickson
> : Web Designer for the offices of Principal and Provost
> : McGill University
> : Tel 514-398-2624 | Fax 514-389-8983
> : [EMAIL PROTECTED]
>
>
>
>
> Get 250 color business cards for FREE!
> http://businesscards.lycos.com/vp/fastpath/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] split() function

2001-07-04 Thread David A Dickson

I have a comma separated spreadsheet with one field that contains two dates. the dates 
are formatted as dd/mm/yy and separated by either '&' or '//' ex:3/12/92&28/1/93 or 
3/12/92//28/1/93
Problem: I need to split the field at the '&' or '//' separator but if I do 
split('[&//]', $field);
it splits on the '/' not the '//'.
Can I do this in one function call to split() or will I have to do it twice?
---
: David A. Dickson
: Web Designer for the offices of Principal and Provost
: McGill University
: Tel 514-398-2624 | Fax 514-389-8983
: [EMAIL PROTECTED]




Get 250 color business cards for FREE!
http://businesscards.lycos.com/vp/fastpath/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]