Re: [PHP] Agh! trim (#$@#@^%!!!)
Instead of trim($str), you need: $str = trim($str); Justin French on 22/08/02 12:44 AM, Mike At Spy ([EMAIL PROTECTED]) wrote: > > But isn't taking off characters or spaces considered modifying a string? > > I'll take another look at the manual, thanks. > > -Mike > > >> -Original Message- >> From: Darren Gamble [mailto:[EMAIL PROTECTED]] >> Sent: Wednesday, August 21, 2002 10:32 AM >> To: 'Mike At Spy'; [EMAIL PROTECTED] >> Subject: RE: [PHP] Agh! trim (#$@#@^%!!!) >> >> >> Good day, >> >> Well, for one, you are discarding the results of trim(). >> >> Check out the online manual page for trim(). The trim'ed string is >> returned. It does not say it modifies the string it is passed. >> >> >> Darren Gamble >> Planner, Regional Services >> Shaw Cablesystems GP >> 630 - 3rd Avenue SW >> Calgary, Alberta, Canada >> T2P 4L4 >> (403) 781-4948 >> >> >>> -Original Message- >>> From: Mike At Spy [mailto:[EMAIL PROTECTED]] >>> Sent: Wednesday, August 21, 2002 7:12 AM >>> To: [EMAIL PROTECTED] >>> Subject: RE: [PHP] Agh! trim (#$@#@^%!!!) >>> >>> >>> >>> Here is the complete code - I have a lot of prints to watch >>> things as they >>> happen. $whois is the result of a WHOIS search. >>> >>> >>> >>> // beginning of my stuff >>> >>> function get_date ($whois){ >>> trim ($whois); >>> $whoisarray = explode ("\n", $whois); >>> print_r(array_values ($whoisarray)); >>> >>> $total_elements = count ($whoisarray); >>> >>> print "$total_elements elements in this array"; >>> >>> $ce = 0; >>> >>> while ($ce < $total_elements){ >>> >>> $single_line = array_pop ($whoisarray); >>> >>> $expiration = strstr ($single_line,"xpires"); >>> >>> if ($expiration != '' || 0) { >>> >>> print "This is the line you want! Line $ce that sez: >>> $single_line"; >>> >>> // $single_line = preg_replace (".", " ", $single_line); >>> >>> $single_line = substr($single_line, 0, -2); >>> >>> // $single_line = rtrim ($single_line," \t\s\n\r"); >>> >>> $getdatearray = explode (" ", $single_line); >>> print_r(array_values ($getdatearray)); >>> >>> $total_expire_elements = count ($getdatearray); >>> >>> print "".$total_expire_elements; >>> >>> $dc = 0; >>> >>> while ($dc < $total_expire_elements){ >>> >>> $element = array_pop($getdatearray); >>> >>> $date_dash = strstr($element,"-"); >>> >>> if ($date_dash != '' || 0){ >>> >>> print "First Detection >>> ".$element; >>> >>> // $trimmed = rtrim ($element," \t."); >>> >>> print "Last print before >>> date function ".$element; >>> >>> month_replace ($element); >>> >>> print "Result after function >>> ".$element.""; >>> >>> $MySQLDate=date_validate($element); >>> if (substr($MySQLDate, 0, 5)=="Error") { >>> // Insert Error Code if you want >>> } else { >>> // Insert Valid Date Code if you want >>> } >>> >>> print "The MySQL Formated date is >>> $MySQLDate"; >>> >>> >>> } >>> else {} >>> >>> $dc++; >>> >>> } >>> >>> >>> } >>> else {} >>> >>> $ce++; >>> >>> } >>> >>> } >>> // end of my stuff >>> >>> >>> Thanks, >>> >>> -Mike >>> >>> >>> >>> >>> >>> >>>> -Original Message- >>>> From: Jason Wong [mailto:[EMAIL PROTECTED]] >>>> Sent: Wednesday, August 21, 2002 8:53 AM >>>> To: [EMAIL PROTECTED] >>>> Subject: Re: [PHP] Agh! trim (#$@#@^%!!!) >>>> >>>> >>>> On Wednesday 21 August 2002 20:36, Mike At Spy wrote: >>>>> Get this - it didn't work! :( >>>>> >>>>> I tried decreasing the -1 to -2 and so on, but nothing on that >>>> either. :( >>>> >>>> Post your exact code which didn't work. >>>> >>>> -- >>>> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk >>>> Open Source Software Systems Integrators >>>> * Web Design & Hosting * Internet & Intranet Applications >>> Development * >>>> >>>> /* >>>> You can't go home again, unless you set $HOME. >>>> */ >>>> >>>> >>>> -- >>>> PHP General Mailing List (http://www.php.net/) >>>> To unsubscribe, visit: http://www.php.net/unsub.php >>>> >>> >>> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, visit: http://www.php.net/unsub.php >> > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Agh! trim (#$@#@^%!!!)
But isn't taking off characters or spaces considered modifying a string? I'll take another look at the manual, thanks. -Mike > -Original Message- > From: Darren Gamble [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 21, 2002 10:32 AM > To: 'Mike At Spy'; [EMAIL PROTECTED] > Subject: RE: [PHP] Agh! trim (#$@#@^%!!!) > > > Good day, > > Well, for one, you are discarding the results of trim(). > > Check out the online manual page for trim(). The trim'ed string is > returned. It does not say it modifies the string it is passed. > > > Darren Gamble > Planner, Regional Services > Shaw Cablesystems GP > 630 - 3rd Avenue SW > Calgary, Alberta, Canada > T2P 4L4 > (403) 781-4948 > > > > -Original Message- > > From: Mike At Spy [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, August 21, 2002 7:12 AM > > To: [EMAIL PROTECTED] > > Subject: RE: [PHP] Agh! trim (#$@#@^%!!!) > > > > > > > > Here is the complete code - I have a lot of prints to watch > > things as they > > happen. $whois is the result of a WHOIS search. > > > > > > > > // beginning of my stuff > > > > function get_date ($whois){ > > trim ($whois); > > $whoisarray = explode ("\n", $whois); > > print_r(array_values ($whoisarray)); > > > > $total_elements = count ($whoisarray); > > > > print "$total_elements elements in this array"; > > > > $ce = 0; > > > > while ($ce < $total_elements){ > > > > $single_line = array_pop ($whoisarray); > > > > $expiration = strstr ($single_line,"xpires"); > > > > if ($expiration != '' || 0) { > > > > print "This is the line you want! Line $ce that sez: > > $single_line"; > > > > // $single_line = preg_replace (".", " ", $single_line); > > > > $single_line = substr($single_line, 0, -2); > > > > // $single_line = rtrim ($single_line," \t\s\n\r"); > > > > $getdatearray = explode (" ", $single_line); > > print_r(array_values ($getdatearray)); > > > > $total_expire_elements = count ($getdatearray); > > > > print "".$total_expire_elements; > > > > $dc = 0; > > > > while ($dc < $total_expire_elements){ > > > > $element = array_pop($getdatearray); > > > > $date_dash = strstr($element,"-"); > > > > if ($date_dash != '' || 0){ > > > > print "First Detection > > ".$element; > > > > // $trimmed = rtrim ($element," \t."); > > > > print "Last print before > > date function ".$element; > > > > month_replace ($element); > > > > print "Result after function > > ".$element.""; > > > > $MySQLDate=date_validate($element); > > if (substr($MySQLDate, 0, 5)=="Error") { > > // Insert Error Code if you want > > } else { > > // Insert Valid Date Code if you want > > } > > > > print "The MySQL Formated date is > > $MySQLDate"; > > > > > > } > > else {} > > > > $dc++; > > > > } > > > > > > } > > else {} > > > > $ce++; > > > > } > > > > } > > // end of my stuff > > > > > > Thanks, > > > > -Mike > > > > > > > > > > > > > > > -Original Message- > > > From: Jason Wong [mailto:[EMAIL PROTECTED]] > > > Sent: Wednesday, August 21, 2002 8:53 AM > > > To: [EMAIL PROTECTED] > > > Subject: Re: [PHP] Agh! trim (#$@#@^%!!!) > > > > > > > > > On Wednesday 21 August 2002 20:36, Mike At Spy wrote: > > > > Get this - it didn't work! :( > > > > > > > > I tried decreasing the -1 to -2 and so on, but nothing on that > > > either. :( > > > > > > Post your exact code which didn't work. > > > > > > -- > > > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > > > Open Source Software Systems Integrators > > > * Web Design & Hosting * Internet & Intranet Applications > > Development * > > > > > > /* > > > You can't go home again, unless you set $HOME. > > > */ > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Agh! trim (#$@#@^%!!!)
Good day, Well, for one, you are discarding the results of trim(). Check out the online manual page for trim(). The trim'ed string is returned. It does not say it modifies the string it is passed. Darren Gamble Planner, Regional Services Shaw Cablesystems GP 630 - 3rd Avenue SW Calgary, Alberta, Canada T2P 4L4 (403) 781-4948 > -Original Message- > From: Mike At Spy [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 21, 2002 7:12 AM > To: [EMAIL PROTECTED] > Subject: RE: [PHP] Agh! trim (#$@#@^%!!!) > > > > Here is the complete code - I have a lot of prints to watch > things as they > happen. $whois is the result of a WHOIS search. > > > > // beginning of my stuff > > function get_date ($whois){ > trim ($whois); > $whoisarray = explode ("\n", $whois); > print_r(array_values ($whoisarray)); > > $total_elements = count ($whoisarray); > > print "$total_elements elements in this array"; > > $ce = 0; > > while ($ce < $total_elements){ > > $single_line = array_pop ($whoisarray); > > $expiration = strstr ($single_line,"xpires"); > > if ($expiration != '' || 0) { > > print "This is the line you want! Line $ce that sez: > $single_line"; > > // $single_line = preg_replace (".", " ", $single_line); > > $single_line = substr($single_line, 0, -2); > > // $single_line = rtrim ($single_line," \t\s\n\r"); > > $getdatearray = explode (" ", $single_line); > print_r(array_values ($getdatearray)); > > $total_expire_elements = count ($getdatearray); > > print "".$total_expire_elements; > > $dc = 0; > > while ($dc < $total_expire_elements){ > > $element = array_pop($getdatearray); > > $date_dash = strstr($element,"-"); > > if ($date_dash != '' || 0){ > > print "First Detection > ".$element; > > // $trimmed = rtrim ($element," \t."); > > print "Last print before > date function ".$element; > > month_replace ($element); > > print "Result after function > ".$element.""; > > $MySQLDate=date_validate($element); > if (substr($MySQLDate, 0, 5)=="Error") { > // Insert Error Code if you want > } else { > // Insert Valid Date Code if you want > } > > print "The MySQL Formated date is > $MySQLDate"; > > > } > else {} > > $dc++; > >} > > > } > else {} > > $ce++; > > } > > } > // end of my stuff > > > Thanks, > > -Mike > > > > > > > > -Original Message- > > From: Jason Wong [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, August 21, 2002 8:53 AM > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP] Agh! trim (#$@#@^%!!!) > > > > > > On Wednesday 21 August 2002 20:36, Mike At Spy wrote: > > > Get this - it didn't work! :( > > > > > > I tried decreasing the -1 to -2 and so on, but nothing on that > > either. :( > > > > Post your exact code which didn't work. > > > > -- > > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > > Open Source Software Systems Integrators > > * Web Design & Hosting * Internet & Intranet Applications > Development * > > > > /* > > You can't go home again, unless you set $HOME. > > */ > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Agh! trim (#$@#@^%!!!)
Mike, What are the character codes of the last few bytes in the string? Please advise, =dn - Original Message - From: "Mike At Spy" <[EMAIL PROTECTED]> To: "Rasmus Lerdorf" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, August 21, 2002 1:36 PM Subject: RE: [PHP] Agh! trim (#$@#@^%!!!) > > Get this - it didn't work! :( > > I tried decreasing the -1 to -2 and so on, but nothing on that either. :( > > -Mike > > > > > -Original Message- > > From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, August 20, 2002 12:45 PM > > To: Mike At Spy > > Cc: [EMAIL PROTECTED] > > Subject: Re: [PHP] Agh! trim (#$@#@^%!!!) > > > > > > Well, perhaps you have something after the . in that string? > > > > You can strip off the last char of a string very simply with: > > > >substr($str,0,-1) > > > > -Rasmus > > > > On Tue, 20 Aug 2002, Mike At Spy wrote: > > > > > > > > Hey! > > > > > > :) > > > > > > I have an issue with trim / triml. Whenever I put a string in > > to trimmed, > > > it refuses to take the period at the end of the string off. > > > > > > I did put more things to trim first, but this is basically what > > I am doing: > > > > > > > > > $single = "The date is 20-Aug-2002." // This is an example - see below > > > $trimmed = rtrim($date, "."); > > > > > > > > > Is there an issue with this? I've tried using trim() too. > > > > > > The source of $single is a reponse from a server. I should > > note that when I > > > put this in as an experiment, it works fine. When I get the > > line from the > > > server, it doesn't work! > > > > > > The only thing I can think of is the possibility that the "." I > > am seeing at > > > the end of the line isn't really one (it looks like a duck, > > copies like a > > > duck, but...isn't a duck??!!). > > > > > > Is there a way to just strip the last character off regardless > > of what it > > > is? > > > > > > Thanks, > > > > > > -Mike > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Agh! trim (#$@#@^%!!!)
Well, do a strlen() on it to see how long it actually is. I bet you have all sorts of stuff trailing that thing. Or you are just making some other really silly mistake. -Rasmus On Wed, 21 Aug 2002, Mike At Spy wrote: > > Get this - it didn't work! :( > > I tried decreasing the -1 to -2 and so on, but nothing on that either. :( > > -Mike > > > > > -Original Message- > > From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] > > Sent: Tuesday, August 20, 2002 12:45 PM > > To: Mike At Spy > > Cc: [EMAIL PROTECTED] > > Subject: Re: [PHP] Agh! trim (#$@#@^%!!!) > > > > > > Well, perhaps you have something after the . in that string? > > > > You can strip off the last char of a string very simply with: > > > >substr($str,0,-1) > > > > -Rasmus > > > > On Tue, 20 Aug 2002, Mike At Spy wrote: > > > > > > > > Hey! > > > > > > :) > > > > > > I have an issue with trim / triml. Whenever I put a string in > > to trimmed, > > > it refuses to take the period at the end of the string off. > > > > > > I did put more things to trim first, but this is basically what > > I am doing: > > > > > > > > > $single = "The date is 20-Aug-2002." // This is an example - see below > > > $trimmed = rtrim($date, "."); > > > > > > > > > Is there an issue with this? I've tried using trim() too. > > > > > > The source of $single is a reponse from a server. I should > > note that when I > > > put this in as an experiment, it works fine. When I get the > > line from the > > > server, it doesn't work! > > > > > > The only thing I can think of is the possibility that the "." I > > am seeing at > > > the end of the line isn't really one (it looks like a duck, > > copies like a > > > duck, but...isn't a duck??!!). > > > > > > Is there a way to just strip the last character off regardless > > of what it > > > is? > > > > > > Thanks, > > > > > > -Mike > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Agh! trim (#$@#@^%!!!)
Here is the complete code - I have a lot of prints to watch things as they happen. $whois is the result of a WHOIS search. // beginning of my stuff function get_date ($whois){ trim ($whois); $whoisarray = explode ("\n", $whois); print_r(array_values ($whoisarray)); $total_elements = count ($whoisarray); print "$total_elements elements in this array"; $ce = 0; while ($ce < $total_elements){ $single_line = array_pop ($whoisarray); $expiration = strstr ($single_line,"xpires"); if ($expiration != '' || 0) { print "This is the line you want! Line $ce that sez: $single_line"; // $single_line = preg_replace (".", " ", $single_line); $single_line = substr($single_line, 0, -2); // $single_line = rtrim ($single_line," \t\s\n\r"); $getdatearray = explode (" ", $single_line); print_r(array_values ($getdatearray)); $total_expire_elements = count ($getdatearray); print "".$total_expire_elements; $dc = 0; while ($dc < $total_expire_elements){ $element = array_pop($getdatearray); $date_dash = strstr($element,"-"); if ($date_dash != '' || 0){ print "First Detection ".$element; // $trimmed = rtrim ($element," \t."); print "Last print before date function ".$element; month_replace ($element); print "Result after function ".$element.""; $MySQLDate=date_validate($element); if (substr($MySQLDate, 0, 5)=="Error") { // Insert Error Code if you want } else { // Insert Valid Date Code if you want } print "The MySQL Formated date is $MySQLDate"; } else {} $dc++; } } else {} $ce++; } } // end of my stuff Thanks, -Mike > -Original Message- > From: Jason Wong [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 21, 2002 8:53 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Agh! trim (#$@#@^%!!!) > > > On Wednesday 21 August 2002 20:36, Mike At Spy wrote: > > Get this - it didn't work! :( > > > > I tried decreasing the -1 to -2 and so on, but nothing on that > either. :( > > Post your exact code which didn't work. > > -- > Jason Wong -> Gremlins Associates -> www.gremlins.com.hk > Open Source Software Systems Integrators > * Web Design & Hosting * Internet & Intranet Applications Development * > > /* > You can't go home again, unless you set $HOME. > */ > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Agh! trim (#$@#@^%!!!)
On Wednesday 21 August 2002 20:36, Mike At Spy wrote: > Get this - it didn't work! :( > > I tried decreasing the -1 to -2 and so on, but nothing on that either. :( Post your exact code which didn't work. -- Jason Wong -> Gremlins Associates -> www.gremlins.com.hk Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* You can't go home again, unless you set $HOME. */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Agh! trim (#$@#@^%!!!)
Get this - it didn't work! :( I tried decreasing the -1 to -2 and so on, but nothing on that either. :( -Mike > -Original Message- > From: Rasmus Lerdorf [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, August 20, 2002 12:45 PM > To: Mike At Spy > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] Agh! trim (#$@#@^%!!!) > > > Well, perhaps you have something after the . in that string? > > You can strip off the last char of a string very simply with: > >substr($str,0,-1) > > -Rasmus > > On Tue, 20 Aug 2002, Mike At Spy wrote: > > > > > Hey! > > > > :) > > > > I have an issue with trim / triml. Whenever I put a string in > to trimmed, > > it refuses to take the period at the end of the string off. > > > > I did put more things to trim first, but this is basically what > I am doing: > > > > > > $single = "The date is 20-Aug-2002." // This is an example - see below > > $trimmed = rtrim($date, "."); > > > > > > Is there an issue with this? I've tried using trim() too. > > > > The source of $single is a reponse from a server. I should > note that when I > > put this in as an experiment, it works fine. When I get the > line from the > > server, it doesn't work! > > > > The only thing I can think of is the possibility that the "." I > am seeing at > > the end of the line isn't really one (it looks like a duck, > copies like a > > duck, but...isn't a duck??!!). > > > > Is there a way to just strip the last character off regardless > of what it > > is? > > > > Thanks, > > > > -Mike > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Agh! trim (#$@#@^%!!!)
Sorry, I mistyped - $date should be $single. Thanks for the suggestions and help to everyone! - I will pursue them. :) -Mike > -Original Message- > From: Justin French [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, August 20, 2002 12:50 PM > To: Mike At Spy; [EMAIL PROTECTED] > Subject: Re: [PHP] Agh! trim (#$@#@^%!!!) > > > > $single = "The date is 20-Aug-2002." // This is an example - see below > > $trimmed = rtrim($date, "."); > > Where is $date? I think your attempting to trim the wrong string. > > This worked for me: > > $single = "The date is 20-Aug-2002."; > $trimmed = rtrim($single, "."); > echo $trimmed; > ?> > > > To slice off the last character of any string, you could use substr(): > > $single = "The date is 20-Aug-2002."; > $trimmed = substr($single, 0, -1); > echo $trimmed; > ?> > > > Justin French > > > > on 21/08/02 2:35 AM, Mike At Spy ([EMAIL PROTECTED]) wrote: > > > > > Hey! > > > > :) > > > > I have an issue with trim / triml. Whenever I put a string in > to trimmed, > > it refuses to take the period at the end of the string off. > > > > I did put more things to trim first, but this is basically what > I am doing: > > > > > > $single = "The date is 20-Aug-2002." // This is an example - see below > > $trimmed = rtrim($date, "."); > > > > > > Is there an issue with this? I've tried using trim() too. > > > > The source of $single is a reponse from a server. I should > note that when I > > put this in as an experiment, it works fine. When I get the > line from the > > server, it doesn't work! > > > > The only thing I can think of is the possibility that the "." I > am seeing at > > the end of the line isn't really one (it looks like a duck, > copies like a > > duck, but...isn't a duck??!!). > > > > Is there a way to just strip the last character off regardless > of what it > > is? > > > > Thanks, > > > > -Mike > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Agh! trim (#$@#@^%!!!)
Sorry, just saw Rasmus' reply, lso I didn't read your code entirely, noticed you specified for the period to be chopped off :) Jeff - Original Message - From: "Jeff Lewis" <[EMAIL PROTECTED]> To: "Mike At Spy" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, August 20, 2002 12:53 PM Subject: Re: [PHP] Agh! trim (#$@#@^%!!!) > Trim clears whitespace not characters (I'm pretty sure), try using this to > rid yourself of the period: > > $trimmed = substr($date, 0, -1); // returns everything but that last > character (the period) > > Jeff > - Original Message - > From: "Mike At Spy" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, August 20, 2002 12:35 PM > Subject: [PHP] Agh! trim (#$@#@^%!!!) > > > > > > Hey! > > > > :) > > > > I have an issue with trim / triml. Whenever I put a string in to trimmed, > > it refuses to take the period at the end of the string off. > > > > I did put more things to trim first, but this is basically what I am > doing: > > > > > > $single = "The date is 20-Aug-2002." // This is an example - see below > > $trimmed = rtrim($date, "."); > > > > > > Is there an issue with this? I've tried using trim() too. > > > > The source of $single is a reponse from a server. I should note that when > I > > put this in as an experiment, it works fine. When I get the line from the > > server, it doesn't work! > > > > The only thing I can think of is the possibility that the "." I am seeing > at > > the end of the line isn't really one (it looks like a duck, copies like a > > duck, but...isn't a duck??!!). > > > > Is there a way to just strip the last character off regardless of what it > > is? > > > > Thanks, > > > > -Mike > > > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Agh! trim (#$@#@^%!!!)
> $single = "The date is 20-Aug-2002." // This is an example - see below > $trimmed = rtrim($date, "."); Where is $date? I think your attempting to trim the wrong string. This worked for me: To slice off the last character of any string, you could use substr(): Justin French on 21/08/02 2:35 AM, Mike At Spy ([EMAIL PROTECTED]) wrote: > > Hey! > > :) > > I have an issue with trim / triml. Whenever I put a string in to trimmed, > it refuses to take the period at the end of the string off. > > I did put more things to trim first, but this is basically what I am doing: > > > $single = "The date is 20-Aug-2002." // This is an example - see below > $trimmed = rtrim($date, "."); > > > Is there an issue with this? I've tried using trim() too. > > The source of $single is a reponse from a server. I should note that when I > put this in as an experiment, it works fine. When I get the line from the > server, it doesn't work! > > The only thing I can think of is the possibility that the "." I am seeing at > the end of the line isn't really one (it looks like a duck, copies like a > duck, but...isn't a duck??!!). > > Is there a way to just strip the last character off regardless of what it > is? > > Thanks, > > -Mike > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Agh! trim (#$@#@^%!!!)
> Trim clears whitespace not characters (I'm pretty sure), try using this to > rid yourself of the period: You can optionally specify that trim should trim any other chars. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Agh! trim (#$@#@^%!!!)
Trim clears whitespace not characters (I'm pretty sure), try using this to rid yourself of the period: $trimmed = substr($date, 0, -1); // returns everything but that last character (the period) Jeff - Original Message - From: "Mike At Spy" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, August 20, 2002 12:35 PM Subject: [PHP] Agh! trim (#$@#@^%!!!) > > Hey! > > :) > > I have an issue with trim / triml. Whenever I put a string in to trimmed, > it refuses to take the period at the end of the string off. > > I did put more things to trim first, but this is basically what I am doing: > > > $single = "The date is 20-Aug-2002." // This is an example - see below > $trimmed = rtrim($date, "."); > > > Is there an issue with this? I've tried using trim() too. > > The source of $single is a reponse from a server. I should note that when I > put this in as an experiment, it works fine. When I get the line from the > server, it doesn't work! > > The only thing I can think of is the possibility that the "." I am seeing at > the end of the line isn't really one (it looks like a duck, copies like a > duck, but...isn't a duck??!!). > > Is there a way to just strip the last character off regardless of what it > is? > > Thanks, > > -Mike > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Agh! trim (#$@#@^%!!!)
Well, perhaps you have something after the . in that string? You can strip off the last char of a string very simply with: substr($str,0,-1) -Rasmus On Tue, 20 Aug 2002, Mike At Spy wrote: > > Hey! > > :) > > I have an issue with trim / triml. Whenever I put a string in to trimmed, > it refuses to take the period at the end of the string off. > > I did put more things to trim first, but this is basically what I am doing: > > > $single = "The date is 20-Aug-2002." // This is an example - see below > $trimmed = rtrim($date, "."); > > > Is there an issue with this? I've tried using trim() too. > > The source of $single is a reponse from a server. I should note that when I > put this in as an experiment, it works fine. When I get the line from the > server, it doesn't work! > > The only thing I can think of is the possibility that the "." I am seeing at > the end of the line isn't really one (it looks like a duck, copies like a > duck, but...isn't a duck??!!). > > Is there a way to just strip the last character off regardless of what it > is? > > Thanks, > > -Mike > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php