Re: [PHP] Splitting a string ...

2010-03-15 Thread shiplu
Here is the regex for you. $company_domain = '\w+'; // replace with your own company domain pattern. $user_name = '\w+'; // replace with your own username pattern $email_domain = '\w+\.\w{2,4}'; // google for standard domain name regex pattern and replace it. $regexp =

[PHP] Splitting a string ...

2010-03-14 Thread Ashley M. Kirchner
I'm not a regexp person (wish I was though), and I'm hoping someone can give me a hand here. Consider the following strings: - domain\usern...@example.org - domain\username - the same as above but with / instead of \ (hey, it happens) -

Re: [PHP] Splitting a string ...

2010-03-14 Thread Jochem Maas
Op 3/15/10 1:54 AM, Ashley M. Kirchner schreef: I'm not a regexp person (wish I was though), and I'm hoping someone can give me a hand here. Consider the following strings: - domain\usern...@example.org - domain\username - the same as above but with /

[PHP] splitting a string

2010-01-05 Thread Ingleby, Les
Hi all, first time I have posted here so please be nice. I am using PEAR HTTP_Upload to handle multiple file uploads. What I need to do is to take the file name which is output using the getProp() function and then remove the file extension from the end of the file for example: Original name

Re: [PHP] splitting a string

2010-01-05 Thread Daniel Egeberg
On Tue, Jan 5, 2010 at 13:39, Ingleby, Les les.in...@tynemet.ac.uk wrote: Hi all, first time I have posted here so please be nice. I am using PEAR HTTP_Upload to handle multiple file uploads. What I need to do is to take the file name which is output using the getProp() function and then

Re: [PHP] splitting a string

2010-01-05 Thread Ashley Sheridan
On Tue, 2010-01-05 at 12:39 +, Ingleby, Les wrote: Hi all, first time I have posted here so please be nice. I am using PEAR HTTP_Upload to handle multiple file uploads. What I need to do is to take the file name which is output using the getProp() function and then remove the file

Re: [PHP] splitting a string

2010-01-05 Thread Daniel Egeberg
On Tue, Jan 5, 2010 at 14:13, Ashley Sheridan a...@ashleysheridan.co.uk wrote: (untested - I always forget the order of the params!) As a general rule, string functions are always haystack-needle and array functions are always needle-haystack. I can't think of any exceptions to that rule. --

Re: [PHP] splitting a string

2010-01-05 Thread Ashley Sheridan
On Tue, 2010-01-05 at 14:26 +0100, Daniel Egeberg wrote: On Tue, Jan 5, 2010 at 14:13, Ashley Sheridan a...@ashleysheridan.co.uk wrote: (untested - I always forget the order of the params!) As a general rule, string functions are always haystack-needle and array functions are always

Re: [PHP] Splitting a string

2006-11-16 Thread Børge Holen
On Thursday 16 November 2006 01:12, Robert Cummings wrote: On Thu, 2006-11-16 at 10:47 +1100, Chris wrote: Børge Holen wrote: Oh this was good. I added a while loop to insert extra strings 0 in front of the number to add if the string is less than 5 chars short. sprintf is your

Re: [PHP] Splitting a string

2006-11-16 Thread Børge Holen
On Thursday 16 November 2006 01:38, Paul Novitski wrote: At 11/15/2006 02:06 PM, Børge Holen wrote: Oh this was good. I added a while loop to insert extra strings 0 in front of the number to add if the string is less than 5 chars short. I forgot to mentinon that the string actually could

Re: [PHP] Splitting a string

2006-11-16 Thread Paul Novitski
On Thursday 16 November 2006 01:38, Paul Novitski wrote: If you need to left-pad with zeroes, PHP comes to the rescue: http://php.net/str_pad However, if you're using the regular expression method then you might not need to pad the number. You can change the pattern from this:

Re: [PHP] Splitting a string

2006-11-15 Thread Robin Vickery
On 15/11/06, Aaron Koning [EMAIL PROTECTED] wrote: Assuming var1 and var2 only ever use the last four numbers (untested): $length = strlen($number); // get string length $var1 = substr($number,0,$length-4); // get number until only 4 numbers are left $var2 = substr($number,$length-4,2); // get

Re: [PHP] Splitting a string

2006-11-15 Thread Børge Holen
On Wednesday 15 November 2006 06:24, you wrote: At 11/14/2006 03:17 PM, Børge Holen wrote: $number = 123456789 should print as following: var1: 12345 (and it is this lengt witch varies) var2: 67 var3: 89. You can also do this with a regular expression: $iNumber = '123456789';

Re: [PHP] Splitting a string

2006-11-15 Thread Børge Holen
On Wednesday 15 November 2006 12:42, Robin Vickery wrote: On 15/11/06, Aaron Koning [EMAIL PROTECTED] wrote: Assuming var1 and var2 only ever use the last four numbers (untested): $length = strlen($number); // get string length $var1 = substr($number,0,$length-4); // get number until only

Re: [PHP] Splitting a string

2006-11-15 Thread Børge Holen
Oh this was good. I added a while loop to insert extra strings 0 in front of the number to add if the string is less than 5 chars short. I forgot to mentinon that the string actually could be shorter (just found out) and the code didn't work with fewer than 5 char strings. But now is rocks.

Re: [PHP] Splitting a string

2006-11-15 Thread Chris
Børge Holen wrote: Oh this was good. I added a while loop to insert extra strings 0 in front of the number to add if the string is less than 5 chars short. sprintf is your friend here, no need to use a loop. sprintf('%05d', '1234'); -- Postgresql php tutorials http://www.designmagick.com/

Re: [PHP] Splitting a string

2006-11-15 Thread Robert Cummings
On Thu, 2006-11-16 at 10:47 +1100, Chris wrote: Børge Holen wrote: Oh this was good. I added a while loop to insert extra strings 0 in front of the number to add if the string is less than 5 chars short. sprintf is your friend here, no need to use a loop. sprintf('%05d', '1234');

Re: [PHP] Splitting a string

2006-11-15 Thread Chris
Robert Cummings wrote: On Thu, 2006-11-16 at 10:47 +1100, Chris wrote: Børge Holen wrote: Oh this was good. I added a while loop to insert extra strings 0 in front of the number to add if the string is less than 5 chars short. sprintf is your friend here, no need to use a loop.

Re: [PHP] Splitting a string

2006-11-15 Thread Paul Novitski
At 11/15/2006 02:06 PM, Børge Holen wrote: Oh this was good. I added a while loop to insert extra strings 0 in front of the number to add if the string is less than 5 chars short. I forgot to mentinon that the string actually could be shorter (just found out) and the code didn't work with

[PHP] Splitting a string

2006-11-14 Thread Børge Holen
This numer has dynamic lenght, witch is the root of my problems. $number = 123456789 should print as following: var1: 12345 (and it is this lengt witch varies) var2: 67 var3: 89. I've been using substr with negative numbers to fetch the last two vars. thereafter explode to get the first

Re: [PHP] Splitting a string

2006-11-14 Thread Darrell Brogdon
What's the code? -D On Nov 14, 2006, at 4:17 PM, Børge Holen wrote: This numer has dynamic lenght, witch is the root of my problems. $number = 123456789 should print as following: var1: 12345 (and it is this lengt witch varies) var2: 67 var3: 89. I've been using substr with negative

Re: [PHP] Splitting a string

2006-11-14 Thread Aaron Koning
Assuming var1 and var2 only ever use the last four numbers (untested): $length = strlen($number); // get string length $var1 = substr($number,0,$length-4); // get number until only 4 numbers are left $var2 = substr($number,$length-4,2); // get 3rd and 4th last numbers. $var3 =

Re: [PHP] Splitting a string

2006-11-14 Thread Paul Novitski
At 11/14/2006 03:17 PM, Børge Holen wrote: $number = 123456789 should print as following: var1: 12345 (and it is this lengt witch varies) var2: 67 var3: 89. You can also do this with a regular expression: $iNumber = '123456789'; $sPattern = '/(\d+)(\d{2})(\d{2})$/'; preg_match($sPattern,

[PHP] Splitting a string by the number of characters in the string?

2004-07-30 Thread Brent Clements
In PHP 5 there is a awesome function called str_split, is there an equivalent in PHP 4.x? I need to do the following: Split a 60 character string into 3 20 character array chunks. using str_split I could easily do it, but how do I do it in PHP 4.x? Thanks, Brent

Re: [PHP] Splitting a string by the number of characters in the string?

2004-07-30 Thread Justin Patrin
On Fri, 30 Jul 2004 02:44:19 -0500, Brent Clements [EMAIL PROTECTED] wrote: In PHP 5 there is a awesome function called str_split, is there an equivalent in PHP 4.x? I need to do the following: Split a 60 character string into 3 20 character array chunks. using str_split I could easily

Re: [PHP] Splitting a string by the number of characters in the string?

2004-07-30 Thread Jason Wong
On Friday 30 July 2004 15:44, Brent Clements wrote: In PHP 5 there is a awesome function called str_split, is there an equivalent in PHP 4.x? I need to do the following: Split a 60 character string into 3 20 character array chunks. using str_split I could easily do it, but how do I do it

[PHP] Splitting a string

2003-03-13 Thread Christopher J. Crane
I have a CSV file that has 7 fields. One of the fields has a number, and some of the numbers start with a S. If that number start with a S, I want to strip it off. I am not sure how to do that. I first wrote the script to open the file, load each line into an array and split the array by field.

Re: [PHP] Splitting a string

2003-03-13 Thread - Edwin
Hi, Christopher J. Crane [EMAIL PROTECTED] wrote: [snip] If that number start with a S, I want to strip it off. [/snip] Why don't you just check whether the first character is an S then return only the rest of the string if it is? Like: ?php $my_string = 'S12345'; if ($my_string{0} ==

Re: [PHP] Splitting a string

2003-03-13 Thread David Otton
On Thu, 13 Mar 2003 09:13:35 -0500, you wrote: Then split the variable where there is a S. The problem showed up when there is another S in the field. I only want to split the first S at the beginning of the field. Isn't there an additional value to add to the split $line = 'S12345'; if

Re: [PHP] Splitting a string

2003-03-13 Thread David Rice
Then split the variable where there is a S. The problem showed up when there is another S in the field. I only want to split the first S at the beginning of the field. Isn't there an additional value to add to the split $line = 'S12345'; if ($line[0] == 'S') { /* do stuff */ } $str =

RE: [PHP] Splitting a string

2003-03-13 Thread Crane, Christopher
-4379 -Original Message- From: - Edwin [mailto:[EMAIL PROTECTED] Sent: Thursday, March 13, 2003 9:30 AM To: Christopher J. Crane; [EMAIL PROTECTED] Subject: Re: [PHP] Splitting a string Hi, Christopher J. Crane [EMAIL PROTECTED] wrote: [snip] If that number start with a S, I want

Re: [PHP] Splitting a string

2003-03-13 Thread - Edwin
Hi, David Rice [EMAIL PROTECTED] wrote: $str = S12345; $str1 = ltrim($str,S); Good idea but you'd have problem if you have $str = SS12345; and you only want to get rid of the first one... - E __ Do You Yahoo!? Yahoo! BB is Broadband by

[PHP] splitting a string in half

2001-07-30 Thread Adam
I wish to split my databased string in half to be shown on 2 seperate columns, but also preserve whole words. Is there a function that does this already? Maybe a quick fix? Hopefully something that doesn't include html tags as part of the string to split. If it's not that specific then that's

[PHP] Splitting a string first by quotes then spaces

2001-07-09 Thread Aaron Bennett
Ok, heres one for y'all I have the user entering a free formed string (such as a search engine query).. and i want to parse that string into an array of string elements... If the user enters elements within double quotes, that would appear as one entity.. for each word outside of containing

Re: [PHP] Splitting a string first by quotes then spaces

2001-07-09 Thread rm
Try this: first test to see if the query contain quotes, if it does, go to a seperate routine that splits the string into an array, first however, you must make sure there is a space before the query and one after the query ( you add these) *then* split the string into an array, explode on the