RE: [PHP] How can I remove the last character from a one line file?

2002-05-30 Thread Rea_David

Hi all,

The problem is nearly solved.  I need my if statement to read the
last character from the file  if it ends with an o, then remove the one
character.  My current if statement allows the action to take place if there
is an o anywhere in the file.  Can somebody help me with this.

My current if statement looks like this:

if (eregi (.*\b,$port)){
$port=substr($port,0,(strlen($port)-1));
}

Thanks alot
Dave

-Original Message-
From: Rea, David 
Sent: 28 May 2002 15:46
To: 'Ed Gorski'
Subject: RE: [PHP] How can I remove the last character from a one line
file? 


That worked a dream,

Thanks Ed!
Dave

-Original Message-
From: Ed Gorski [mailto:[EMAIL PROTECTED]]
Sent: 28 May 2002 14:41
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] How can I remove the last character from a one line
file? 


Try:

$string=Jacko;
$string=substr($string,0,(strlen($string)-1));
echo $string;

ed

At 09:35 AM 5/28/2002 -0400, [EMAIL PROTECTED] wrote:
Hi all,

 How can I remove the last character from a one line file?
 i.e. I need to change Jacko to Jack


I would really appreciate a response on this!

Thank you!
Dave

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Edmund Gorski
Programmer / Analyst
WWW Coordinator Dept. @ District Office
727-341-3181


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] How can I remove the last character from a one line file?

2002-05-30 Thread Niklas Lampén

eregi_replace(o$, , $String);


Niklas


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] 
Sent: 30. toukokuuta 2002 13:05
To: [EMAIL PROTECTED]
Subject: RE: [PHP] How can I remove the last character from a one line
file? 


Hi all,

The problem is nearly solved.  I need my if statement to read
the last character from the file  if it ends with an o, then remove the
one character.  My current if statement allows the action to take place
if there is an o anywhere in the file.  Can somebody help me with this.

My current if statement looks like this:

if (eregi (.*\b,$port)){
$port=substr($port,0,(strlen($port)-1));
}

Thanks alot
Dave

-Original Message-
From: Rea, David 
Sent: 28 May 2002 15:46
To: 'Ed Gorski'
Subject: RE: [PHP] How can I remove the last character from a one line
file? 


That worked a dream,

Thanks Ed!
Dave

-Original Message-
From: Ed Gorski [mailto:[EMAIL PROTECTED]]
Sent: 28 May 2002 14:41
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] How can I remove the last character from a one line
file? 


Try:

$string=Jacko;
$string=substr($string,0,(strlen($string)-1));
echo $string;

ed

At 09:35 AM 5/28/2002 -0400, [EMAIL PROTECTED] wrote:
Hi all,

 How can I remove the last character from a one line file?
 i.e. I need to change Jacko to Jack


I would really appreciate a response on this!

Thank you!
Dave

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Edmund Gorski
Programmer / Analyst
WWW Coordinator Dept. @ District Office
727-341-3181


-- 
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] How can I remove the last character from a one line file?

2002-05-30 Thread James Holden



Function StripLastChar( $file ){
$fp = fopen($file,r);
if ($fp){
$contents = fread($fp,10);
fclose($fp);
}
$contents = eregi_replace(o$,,$contents);
return $contents;
}


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: 30 May 2002 11:05
To: [EMAIL PROTECTED]
Subject: RE: [PHP] How can I remove the last character from a one line
file?


Hi all,

The problem is nearly solved.  I need my if statement to read the
last character from the file  if it ends with an o, then remove the one
character.  My current if statement allows the action to take place if there
is an o anywhere in the file.  Can somebody help me with this.

My current if statement looks like this:

if (eregi (.*\b,$port)){
$port=substr($port,0,(strlen($port)-1));
}

Thanks alot
Dave

-Original Message-
From: Rea, David
Sent: 28 May 2002 15:46
To: 'Ed Gorski'
Subject: RE: [PHP] How can I remove the last character from a one line
file?


That worked a dream,

Thanks Ed!
Dave

-Original Message-
From: Ed Gorski [mailto:[EMAIL PROTECTED]]
Sent: 28 May 2002 14:41
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] How can I remove the last character from a one line
file?


Try:

$string=Jacko;
$string=substr($string,0,(strlen($string)-1));
echo $string;

ed

At 09:35 AM 5/28/2002 -0400, [EMAIL PROTECTED] wrote:
Hi all,

 How can I remove the last character from a one line file?
 i.e. I need to change Jacko to Jack


I would really appreciate a response on this!

Thank you!
Dave

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Edmund Gorski
Programmer / Analyst
WWW Coordinator Dept. @ District Office
727-341-3181


--
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] How can I remove the last character from a one line file?

2002-05-28 Thread Rea_David

Hi all,

How can I remove the last character from a one line file? 
i.e. I need to change Jacko to Jack


I would really appreciate a response on this!

Thank you!
Dave

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] How can I remove the last character from a one line file?

2002-05-28 Thread Ed Gorski

Try:

$string=Jacko;
$string=substr($string,0,(strlen($string)-1));
echo $string;

ed

At 09:35 AM 5/28/2002 -0400, [EMAIL PROTECTED] wrote:
Hi all,

 How can I remove the last character from a one line file?
 i.e. I need to change Jacko to Jack


I would really appreciate a response on this!

Thank you!
Dave

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Edmund Gorski
Programmer / Analyst
WWW Coordinator Dept. @ District Office
727-341-3181



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] How can I remove the last character from a one line file?

2002-05-28 Thread Scott Hurring

TIMTOWTDI

$string = Jacko;
print preg_replace('/.$/', '', $string);

---
Scott Hurring
Systems Programmer
EAC Corporation
[EMAIL PROTECTED]
Voice: 201-462-2149
Fax: 201-288-1515

 -Original Message-
 From: Ed Gorski [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, May 28, 2002 9:41 AM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: [PHP] How can I remove the last character from a one line
 file? 
 
 
 Try:
 
 $string=Jacko;
 $string=substr($string,0,(strlen($string)-1));
 echo $string;
 
 ed
 
 At 09:35 AM 5/28/2002 -0400, [EMAIL PROTECTED] wrote:
 Hi all,
 
  How can I remove the last character from a one line file?
  i.e. I need to change Jacko to Jack
 
 
 I would really appreciate a response on this!
 
 Thank you!
 Dave
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 Edmund Gorski
 Programmer / Analyst
 WWW Coordinator Dept. @ District Office
 727-341-3181
 
 
 
 -- 
 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] How can I remove the last character from a one line file?

2002-05-28 Thread Rasmus Lerdorf

Ouch!

echo substr($string,0,-1);

is much more efficient.

-Rasmus

On Tue, 28 May 2002, Scott Hurring wrote:

 TIMTOWTDI

 $string = Jacko;
 print preg_replace('/.$/', '', $string);

 ---
 Scott Hurring
 Systems Programmer
 EAC Corporation
 [EMAIL PROTECTED]
 Voice: 201-462-2149
 Fax: 201-288-1515

  -Original Message-
  From: Ed Gorski [mailto:[EMAIL PROTECTED]]
  Sent: Tuesday, May 28, 2002 9:41 AM
  To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Subject: Re: [PHP] How can I remove the last character from a one line
  file?
 
 
  Try:
 
  $string=Jacko;
  $string=substr($string,0,(strlen($string)-1));
  echo $string;
 
  ed
 
  At 09:35 AM 5/28/2002 -0400, [EMAIL PROTECTED] wrote:
  Hi all,
  
   How can I remove the last character from a one line file?
   i.e. I need to change Jacko to Jack
  
  
  I would really appreciate a response on this!
  
  Thank you!
  Dave
  
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
  
  Edmund Gorski
  Programmer / Analyst
  WWW Coordinator Dept. @ District Office
  727-341-3181
  
 
 
  --
  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] How can I remove the last character from a one line file?

2002-05-28 Thread Kevin Porter

Or just:

$string = Jacko;
$string = substr( $string, 0, -1 );
echo $string;

The third argument to substr() means 'one character from the end', see
http://www.php.net/manual/en/function.substr.php

- Kev

 -Original Message-
 From: Ed Gorski [SMTP:[EMAIL PROTECTED]]
 Sent: 28 May 2002 14:41
 To:   [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject:  Re: [PHP] How can I remove the last character from a one
 line file? 
 
 Try:
 
 $string=Jacko;
 $string=substr($string,0,(strlen($string)-1));
 echo $string;
 
 ed
 
 At 09:35 AM 5/28/2002 -0400, [EMAIL PROTECTED] wrote:
 Hi all,
 
  How can I remove the last character from a one line file?
  i.e. I need to change Jacko to Jack
 
 
 I would really appreciate a response on this!
 
 Thank you!
 Dave
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 Edmund Gorski
 Programmer / Analyst
 WWW Coordinator Dept. @ District Office
 727-341-3181
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


**
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
**

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php