RE: [PHP] preg_replace - understanding

2003-07-09 Thread Ford, Mike [LSS]
 -Original Message-
 From: Jennifer Goodie [mailto:[EMAIL PROTECTED]
 Sent: 09 July 2003 00:43
 
  $filevalue = str_replace(\\, /, $filevalue);
 
  it is reversing the \\ to // but not replacing them 
 with just a single
  /.
 
 I think you need to escape your \ so each \ is \\ so your 
 string should be
 

Or use single quotes for your strings:

  $filevalue = str_replace('\\', '/', $filevalue);

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



[PHP] preg_replace - understanding

2003-07-08 Thread Micah Montoy
I'm trying to understand how the code works within the preg_replace function
but the manual is just obscure as the examples are.  Anyway, I am looking to
use it to replace \\ in a string with / and I can not figure how how.
At first, I thought I could just do:

$filevalue = preg_replace('\\', /, $filevalue);

but it doesn't do anything.  If someone could relate what it is and what the
parts mean between the (), I would appreciate it.

thanks



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



Fw: [PHP] preg_replace - understanding

2003-07-08 Thread Kevin Stone

- Original Message -
From: Micah Montoy [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 4:01 PM
Subject: [PHP] preg_replace - understanding


 I'm trying to understand how the code works within the preg_replace
function
 but the manual is just obscure as the examples are.  Anyway, I am looking
to
 use it to replace \\ in a string with / and I can not figure how how.
 At first, I thought I could just do:

 $filevalue = preg_replace('\\', /, $filevalue);

 but it doesn't do anything.  If someone could relate what it is and what
the
 parts mean between the (), I would appreciate it.

 thanks

You're not using the function correctly.  You've got the search string and
replace string tied up into one input there.  They need to be separate.

$filevalue = preg_replace('\\', '/', $filevalue);
http://www.php.net/manual/en/function.preg-replace.php

However you should consider using the str_replace() function in your case
since you aren't doing any pattern matching and it's a lot faster than
preg_replace().

$filevalue = str_replace('\\'. '/', $filevalue);
http://www.php.net/manual/en/function.str-replace.php

--
Kevin



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



Re: [PHP] preg_replace - understanding

2003-07-08 Thread Micah Montoy
I took a look at the str_replace function and it will work but I am getting
a weird thing happening now.  When I do:

$filevalue = str_replace(\\, /, $filevalue);

it is reversing the \\ to // but not replacing them with just a single
/.

What may be causing this?

thanks


Kevin Stone [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 - Original Message -
 From: Micah Montoy [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, July 08, 2003 4:01 PM
 Subject: [PHP] preg_replace - understanding


  I'm trying to understand how the code works within the preg_replace
 function
  but the manual is just obscure as the examples are.  Anyway, I am
looking
 to
  use it to replace \\ in a string with / and I can not figure how
how.
  At first, I thought I could just do:
 
  $filevalue = preg_replace('\\', /, $filevalue);
 
  but it doesn't do anything.  If someone could relate what it is and what
 the
  parts mean between the (), I would appreciate it.
 
  thanks

 You're not using the function correctly.  You've got the search string and
 replace string tied up into one input there.  They need to be separate.

 $filevalue = preg_replace('\\', '/', $filevalue);
 http://www.php.net/manual/en/function.preg-replace.php

 However you should consider using the str_replace() function in your case
 since you aren't doing any pattern matching and it's a lot faster than
 preg_replace().

 $filevalue = str_replace('\\'. '/', $filevalue);
 http://www.php.net/manual/en/function.str-replace.php

 --
 Kevin





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



RE: [PHP] preg_replace - understanding

2003-07-08 Thread Jennifer Goodie
 $filevalue = str_replace(\\, /, $filevalue);

 it is reversing the \\ to // but not replacing them with just a single
 /.

I think you need to escape your \ so each \ is \\ so your string should be




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



Re: [PHP] preg_replace - understanding

2003-07-08 Thread Micah Montoya
You where right.  That's what it was doing but now its not reversing the
direction.  It at least is a single \.  Have an idea for reversing it.  I
played with it a bit but still no go on this.

thanks


- Original Message - 
From: Jennifer Goodie [EMAIL PROTECTED]
To: Micah Montoy [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 5:43 PM
Subject: RE: [PHP] preg_replace - understanding


  $filevalue = str_replace(\\, /, $filevalue);
 
  it is reversing the \\ to // but not replacing them with just a
single
  /.

 I think you need to escape your \ so each \ is \\ so your string should be
 






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



Re: [PHP] preg_replace - understanding

2003-07-08 Thread Micah Montoya
Never mind.  Its working.

thanks

- Original Message - 
From: Jennifer Goodie [EMAIL PROTECTED]
To: Micah Montoy [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 5:43 PM
Subject: RE: [PHP] preg_replace - understanding


  $filevalue = str_replace(\\, /, $filevalue);
 
  it is reversing the \\ to // but not replacing them with just a
single
  /.

 I think you need to escape your \ so each \ is \\ so your string should be
 






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