Re: [PHP] Replace a space with a newline every 2 spaces

2010-04-22 Thread Andrew Ballard
On Thu, Apr 22, 2010 at 1:29 PM, Paul Halliday  wrote:
> Ex:
>
> "This is the string and it is this long"
>
> This is
> the string
> and it
> is this
> long
>
> I found some long functions to achieve this but I couldn't help but
> think that it could be done in a couple lines.
>
> Possible?
>
> Thanks.
>

I'm not sure it's the best method, but it didn't take long to come up with this:



Andrew

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



[PHP] Replace a space with a newline every 2 spaces

2010-04-22 Thread Paul Halliday
Ex:

"This is the string and it is this long"

This is
the string
and it
is this
long

I found some long functions to achieve this but I couldn't help but
think that it could be done in a couple lines.

Possible?

Thanks.

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



RE: [PHP] Replace in a string with regex

2009-07-22 Thread rszeus
Thank you very much!
Understand. And it Works very well now.

Cheers

-Mensagem original-
De: Ford, Mike [mailto:m.f...@leedsmet.ac.uk] 
Enviada: quinta-feira, 23 de Julho de 2009 00:04
Para: php-general@lists.php.net
Assunto: RE: [PHP] Replace in a string with regex

> -Original Message-
> From: rszeus [mailto:rsz...@gmail.com]
> Sent: 22 July 2009 19:23
> To: 'Jim Lucas'
> Cc: 'Kyle Smith'; 'Eddie Drapkin'; a...@ashleysheridan.co.uk; php-
> gene...@lists.php.net
> Subject: RE: [PHP] Replace in a string with regex
> 
> No, sory, my bad typing. It's not the problem..
> I have the same on both caxses, only chnage the variable $id
>  $file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg"
>  $id = '70';
>  echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,
> $file);
>  Get: 0
> 
> file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg";
> $id = test;
> echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,
> $file);
> 
> Get: screen/test
> 
> What is wrong with having na integer on the var ?

Well, the problem here is that when you concatenate $id containing 70 on to 
'$1', you effectively end up with '$170' -- which the manual page at 
http://php.net/preg-replace makes clear is ambiguous, but is likely to be 
treated as $17 followed by a zero, rather than $1 followed by 70. Since $17 
doesn't exist (as you don't have that many capturing subpatterns in your 
pattern!), it is taken to be the null string -- leaving just the left over 0 as 
the result of the replacement. QED.

The workaround for this is also given on the page referenced above, which is to 
make your replacement be '${1}'.$id.

Incidentally, I don't really see the need for the $1, or the equivalent 
parentheses in the pattern -- since a fixed string is involved, why not just 
use it directly in both places? Like this:

   preg_replace('#screen/temp/(.+?)_1(.+?\.jpg)#', 'screen/'.$id, $file);

which completely sidesteps the problem.

Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730




To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


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



RE: [PHP] Replace in a string with regex

2009-07-22 Thread Ford, Mike
> -Original Message-
> From: rszeus [mailto:rsz...@gmail.com]
> Sent: 22 July 2009 19:23
> To: 'Jim Lucas'
> Cc: 'Kyle Smith'; 'Eddie Drapkin'; a...@ashleysheridan.co.uk; php-
> gene...@lists.php.net
> Subject: RE: [PHP] Replace in a string with regex
> 
> No, sory, my bad typing. It's not the problem..
> I have the same on both caxses, only chnage the variable $id
>  $file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg"
>  $id = '70';
>  echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,
> $file);
>  Get: 0
> 
> file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg";
> $id = test;
> echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,
> $file);
> 
> Get: screen/test
> 
> What is wrong with having na integer on the var ?

Well, the problem here is that when you concatenate $id containing 70 on to 
'$1', you effectively end up with '$170' -- which the manual page at 
http://php.net/preg-replace makes clear is ambiguous, but is likely to be 
treated as $17 followed by a zero, rather than $1 followed by 70. Since $17 
doesn't exist (as you don't have that many capturing subpatterns in your 
pattern!), it is taken to be the null string -- leaving just the left over 0 as 
the result of the replacement. QED.

The workaround for this is also given on the page referenced above, which is to 
make your replacement be '${1}'.$id.

Incidentally, I don't really see the need for the $1, or the equivalent 
parentheses in the pattern -- since a fixed string is involved, why not just 
use it directly in both places? Like this:

   preg_replace('#screen/temp/(.+?)_1(.+?\.jpg)#', 'screen/'.$id, $file);

which completely sidesteps the problem.

Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730




To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


Re: [PHP] Replace in a string with regex

2009-07-22 Thread Jim Lucas
rszeus wrote:
> No, sory, my bad typing. It's not the problem..
> I have the same on both caxses, only chnage the variable $id 
>  $file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg" 
>  $id = '70';
>  echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);
>  Get: 0
>  
> file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg";
> $id = test;

Well, here you are trying to use a constant called test to set your
variable $id.  I would try surrounding test with single or double quotes

> echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);
> 
> Get: screen/test
> 
> What is wrong with having na integer on the var ?
> 
> Thank you
> 
> -Mensagem original-
> De: Jim Lucas [mailto:li...@cmsws.com] 
> Enviada: quarta-feira, 22 de Julho de 2009 18:44
> Para: rszeus
> Cc: 'Kyle Smith'; 'Eddie Drapkin'; a...@ashleysheridan.co.uk; 
> php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
> 
> rszeus wrote:
>> Thank you. I undestand now.
>>
>> Anh it’s already workyng the replacemente with letteres. Bu if the variabele 
>> is a number it doens’t work. Any ideas ?
>>
>>  
>>
>> $file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg";
>>
>>  
>>
>> $id = '70';
>>
>>  echo preg_replace('#(Iscreen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);
>>
> 
> You have a great big capital I in there...  Try removing that and see
> what happens.
> 
> 
>> I get 0
>>
>>  
>>
>>  
>>
>> $id = 'test';
>>
>>  echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);
>>
>> I get screen/test
>>
>>  
>>
>> Any ideas ?
>>
>>  
>>
>> Thank you
>>
>>  
>>
>> De: Kyle Smith [mailto:kyle.sm...@inforonics.com] 
>> Enviada: quarta-feira, 22 de Julho de 2009 17:22
>> Para: rszeus
>> Cc: 'Eddie Drapkin'; a...@ashleysheridan.co.uk; 'Jim Lucas'; 
>> php-general@lists.php.net
>> Assunto: Re: [PHP] Replace in a string with regex
>>
>>  
>>
>> The first match inside () is assigned to $1, the second is assigned to $2, 
>> and so on.
>>
>> rszeus wrote: 
>>
>> Hi, 
>> It doens't work.
>> I get 0_main.jpg if I do that..
>> I don't undestand the point of $1 $2 and $3..
>> In preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', what will be $1 and 
>> $2 and $3 ?
>> $ " I already knwo it's the (.+?) but the others didnt' get it.
>>  
>> Thank you...
>>  
>> -Mensagem original-
>> De: Eddie Drapkin [mailto:oorza...@gmail.com] 
>> Enviada: quarta-feira, 22 de Julho de 2009 16:03
>> Para: a...@ashleysheridan.co.uk
>> Cc: Jim Lucas; rszeus; php-general@lists.php.net
>> Assunto: Re: [PHP] Replace in a string with regex
>>  
>> On Wed, Jul 22, 2009 at 11:01 AM, Ashley
>> Sheridan <mailto:a...@ashleysheridan.co.uk>  
>> wrote:
>>   
>>
>> On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote:
>> 
>>
>> rszeus wrote:
>>   
>>
>> Thank you.
>>  
>> What about instead test i want to insert a variable ?
>> Like
>> $id = "30";
>> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file);
>> 
>>
>> Sure that can be done.  But you will need to change the second argument
>> to have double quotes so it will be parsed by PHP.
>>  
>> Then I would surround YOUR variable with curly brackets to separate it
>> from the rest.
>>  
>> echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#',
>>   "$1{$id}$3",
>>   $file);
>>  
>>   
>>
>> I am confusing " and '.
>>  
>> Thank you
>>  
>>  
>> -Mensagem original-
>> De: Eddie Drapkin [mailto:oorza...@gmail.com]
>> Enviada: quarta-feira, 22 de Julho de 2009 14:12
>> Para: rszeus
>> Cc: php-general@lists.php.net
>> Assunto: Re: [PHP] Replace in a string with regex
>>  
>> On Wed, Jul 22, 2009 at 9:07 AM, rszeus <mailto:rsz...@gmail.com> 
>>  wrote:
>> 
>>
>> Hi. It Works to remove the _1 but it doesn'

RE: [PHP] Replace in a string with regex

2009-07-22 Thread rszeus
No, sory, my bad typing. It's not the problem..
I have the same on both caxses, only chnage the variable $id 
 $file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg" 
 $id = '70';
 echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);
 Get: 0
 
file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg";
$id = test;
echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);

Get: screen/test

What is wrong with having na integer on the var ?

Thank you

-Mensagem original-
De: Jim Lucas [mailto:li...@cmsws.com] 
Enviada: quarta-feira, 22 de Julho de 2009 18:44
Para: rszeus
Cc: 'Kyle Smith'; 'Eddie Drapkin'; a...@ashleysheridan.co.uk; 
php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex

rszeus wrote:
> Thank you. I undestand now.
> 
> Anh it’s already workyng the replacemente with letteres. Bu if the variabele 
> is a number it doens’t work. Any ideas ?
> 
>  
> 
> $file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg";
> 
>  
> 
> $id = '70';
> 
>  echo preg_replace('#(Iscreen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);
> 

You have a great big capital I in there...  Try removing that and see
what happens.


> I get 0
> 
>  
> 
>  
> 
> $id = 'test';
> 
>  echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);
> 
> I get screen/test
> 
>  
> 
> Any ideas ?
> 
>  
> 
> Thank you
> 
>  
> 
> De: Kyle Smith [mailto:kyle.sm...@inforonics.com] 
> Enviada: quarta-feira, 22 de Julho de 2009 17:22
> Para: rszeus
> Cc: 'Eddie Drapkin'; a...@ashleysheridan.co.uk; 'Jim Lucas'; 
> php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
> 
>  
> 
> The first match inside () is assigned to $1, the second is assigned to $2, 
> and so on.
> 
> rszeus wrote: 
> 
> Hi, 
> It doens't work.
> I get 0_main.jpg if I do that..
> I don't undestand the point of $1 $2 and $3..
> In preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', what will be $1 and 
> $2 and $3 ?
> $ " I already knwo it's the (.+?) but the others didnt' get it.
>  
> Thank you...
>  
> -Mensagem original-
> De: Eddie Drapkin [mailto:oorza...@gmail.com] 
> Enviada: quarta-feira, 22 de Julho de 2009 16:03
> Para: a...@ashleysheridan.co.uk
> Cc: Jim Lucas; rszeus; php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
>  
> On Wed, Jul 22, 2009 at 11:01 AM, Ashley
> Sheridan <mailto:a...@ashleysheridan.co.uk>  wrote:
>   
> 
> On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote:
> 
> 
> rszeus wrote:
>   
> 
> Thank you.
>  
> What about instead test i want to insert a variable ?
> Like
> $id = "30";
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file);
> 
> 
> Sure that can be done.  But you will need to change the second argument
> to have double quotes so it will be parsed by PHP.
>  
> Then I would surround YOUR variable with curly brackets to separate it
> from the rest.
>  
> echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#',
>   "$1{$id}$3",
>   $file);
>  
>   
> 
> I am confusing " and '.
>  
> Thank you
>  
>  
> -Mensagem original-----
> De: Eddie Drapkin [mailto:oorza...@gmail.com]
> Enviada: quarta-feira, 22 de Julho de 2009 14:12
> Para: rszeus
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
>  
> On Wed, Jul 22, 2009 at 9:07 AM, rszeus <mailto:rsz...@gmail.com> 
>  wrote:
> 
> 
> Hi. It Works to remove the _1 but it doesn't replace 
> '7a45gfdi6icpan1jtb1j99o925' for 'test'
>  
> Thank you
>  
> -Mensagem original-
> De: Eddie Drapkin [mailto:oorza...@gmail.com]
> Enviada: quarta-feira, 22 de Julho de 2009 13:11
> Para: rszeus
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
>  
> On Wed, Jul 22, 2009 at 8:02 AM, rszeus <mailto:rsz...@gmail.com> 
>  wrote:
>   
> 
> Hello,
>  
> I’m tryng to make some replacements on a string.
>  
> Everything goês fine until the regular expression.
>  
>  
>  
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>  
> echo $a =  str_replace(array(7a45gfdi6icp

Re: [PHP] Replace in a string with regex

2009-07-22 Thread Jim Lucas
rszeus wrote:
> Thank you. I undestand now.
> 
> Anh it’s already workyng the replacemente with letteres. Bu if the variabele 
> is a number it doens’t work. Any ideas ?
> 
>  
> 
> $file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg";
> 
>  
> 
> $id = '70';
> 
>  echo preg_replace('#(Iscreen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);
> 

You have a great big capital I in there...  Try removing that and see
what happens.


> I get 0
> 
>  
> 
>  
> 
> $id = 'test';
> 
>  echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);
> 
> I get screen/test
> 
>  
> 
> Any ideas ?
> 
>  
> 
> Thank you
> 
>  
> 
> De: Kyle Smith [mailto:kyle.sm...@inforonics.com] 
> Enviada: quarta-feira, 22 de Julho de 2009 17:22
> Para: rszeus
> Cc: 'Eddie Drapkin'; a...@ashleysheridan.co.uk; 'Jim Lucas'; 
> php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
> 
>  
> 
> The first match inside () is assigned to $1, the second is assigned to $2, 
> and so on.
> 
> rszeus wrote: 
> 
> Hi, 
> It doens't work.
> I get 0_main.jpg if I do that..
> I don't undestand the point of $1 $2 and $3..
> In preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', what will be $1 and 
> $2 and $3 ?
> $ " I already knwo it's the (.+?) but the others didnt' get it.
>  
> Thank you...
>  
> -Mensagem original-
> De: Eddie Drapkin [mailto:oorza...@gmail.com] 
> Enviada: quarta-feira, 22 de Julho de 2009 16:03
> Para: a...@ashleysheridan.co.uk
> Cc: Jim Lucas; rszeus; php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
>  
> On Wed, Jul 22, 2009 at 11:01 AM, Ashley
> Sheridan <mailto:a...@ashleysheridan.co.uk>  wrote:
>   
> 
> On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote:
> 
> 
> rszeus wrote:
>   
> 
> Thank you.
>  
> What about instead test i want to insert a variable ?
> Like
> $id = "30";
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file);
> 
> 
> Sure that can be done.  But you will need to change the second argument
> to have double quotes so it will be parsed by PHP.
>  
> Then I would surround YOUR variable with curly brackets to separate it
> from the rest.
>  
> echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#',
>   "$1{$id}$3",
>   $file);
>  
>   
> 
> I am confusing " and '.
>  
> Thank you
>  
>  
> -Mensagem original-
> De: Eddie Drapkin [mailto:oorza...@gmail.com]
> Enviada: quarta-feira, 22 de Julho de 2009 14:12
> Para: rszeus
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
>  
> On Wed, Jul 22, 2009 at 9:07 AM, rszeus <mailto:rsz...@gmail.com> 
>  wrote:
> 
> 
> Hi. It Works to remove the _1 but it doesn't replace 
> '7a45gfdi6icpan1jtb1j99o925' for 'test'
>  
> Thank you
>  
> -Mensagem original-
> De: Eddie Drapkin [mailto:oorza...@gmail.com]
> Enviada: quarta-feira, 22 de Julho de 2009 13:11
> Para: rszeus
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
>  
> On Wed, Jul 22, 2009 at 8:02 AM, rszeus <mailto:rsz...@gmail.com> 
>  wrote:
>   
> 
> Hello,
>  
> I’m tryng to make some replacements on a string.
>  
> Everything goês fine until the regular expression.
>  
>  
>  
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>  
> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
>  
>  
>  
> The idea is to remove /temp and the last _1 from the file name..but i’m only
> getting this:
>  
> screens/test_1_main.jpg
>  
>  
>  
> I want it to be: screens/test_main.jpg
>  
>  
>  
> Thank you
>  
>  
>  
>  
> 
> 
> If you're trying to do a regular expression based search and replace,
> you probably ought to use preg_replace instead of str_replace, as
> str_replace doesn't parse regular expressions.
>  
> Try this one out, I think I got what you wanted to do:
>  
>   
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>  
> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3&

RE: [PHP] Replace in a string with regex

2009-07-22 Thread rszeus
Thank you. I undestand now.

Anh it’s already workyng the replacemente with letteres. Bu if the variabele is 
a number it doens’t work. Any ideas ?

 

$file = "screen/temp/7a45gfdi6icpan1jtb1j99o925_1_mini.jpg";

 

$id = '70';

 echo preg_replace('#(Iscreen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);

I get 0

 

 

$id = 'test';

 echo preg_replace('#(screen/)temp/(.+?)_1(.+?\.jpg)#', '$1'.$id,  $file);

I get screen/test

 

Any ideas ?

 

Thank you

 

De: Kyle Smith [mailto:kyle.sm...@inforonics.com] 
Enviada: quarta-feira, 22 de Julho de 2009 17:22
Para: rszeus
Cc: 'Eddie Drapkin'; a...@ashleysheridan.co.uk; 'Jim Lucas'; 
php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex

 

The first match inside () is assigned to $1, the second is assigned to $2, and 
so on.

rszeus wrote: 

Hi, 
It doens't work.
I get 0_main.jpg if I do that..
I don't undestand the point of $1 $2 and $3..
In preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', what will be $1 and $2 
and $3 ?
$ " I already knwo it's the (.+?) but the others didnt' get it.
 
Thank you...
 
-Mensagem original-
De: Eddie Drapkin [mailto:oorza...@gmail.com] 
Enviada: quarta-feira, 22 de Julho de 2009 16:03
Para: a...@ashleysheridan.co.uk
Cc: Jim Lucas; rszeus; php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex
 
On Wed, Jul 22, 2009 at 11:01 AM, Ashley
Sheridan <mailto:a...@ashleysheridan.co.uk>  wrote:
  

On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote:


rszeus wrote:
  

Thank you.
 
What about instead test i want to insert a variable ?
Like
$id = "30";
$file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file);


Sure that can be done.  But you will need to change the second argument
to have double quotes so it will be parsed by PHP.
 
Then I would surround YOUR variable with curly brackets to separate it
from the rest.
 
echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#',
  "$1{$id}$3",
  $file);
 
  

I am confusing " and '.
 
Thank you
 
 
-Mensagem original-
De: Eddie Drapkin [mailto:oorza...@gmail.com]
Enviada: quarta-feira, 22 de Julho de 2009 14:12
Para: rszeus
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex
 
On Wed, Jul 22, 2009 at 9:07 AM, rszeus <mailto:rsz...@gmail.com> 
 wrote:


Hi. It Works to remove the _1 but it doesn't replace 
'7a45gfdi6icpan1jtb1j99o925' for 'test'
 
Thank you
 
-Mensagem original-
De: Eddie Drapkin [mailto:oorza...@gmail.com]
Enviada: quarta-feira, 22 de Julho de 2009 13:11
Para: rszeus
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex
 
On Wed, Jul 22, 2009 at 8:02 AM, rszeus <mailto:rsz...@gmail.com> 
 wrote:
  

Hello,
 
I’m tryng to make some replacements on a string.
 
Everything goês fine until the regular expression.
 
 
 
$file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
 
echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
'temp/',’_([0-9])’), array(“test”,"",””), $file)
 
 
 
The idea is to remove /temp and the last _1 from the file name..but i’m only
getting this:
 
screens/test_1_main.jpg
 
 
 
I want it to be: screens/test_main.jpg
 
 
 
Thank you
 
 
 
 


If you're trying to do a regular expression based search and replace,
you probably ought to use preg_replace instead of str_replace, as
str_replace doesn't parse regular expressions.
 
Try this one out, I think I got what you wanted to do:
 
http://www.regular-expressions.info/ is a pretty great free resource,
as ridiculous as the design is.
 
 


 
 
  

I tested this, with the double quotes and the curly braces around the
middle argument (to avoid PHP getting confused) and it didn't recognise
the matches by the numbered $1, $3, etc. I know I'm not the op who asked
the original question, but it might help him/her?
 
Thanks
Ash
www.ashleysheridan.co.uk
 
 


 
To avoid confusion, rather than something like
"$1{$id}$3"
Which looks really indecipherable, I'd definitely think something like
'$1' . $id . '$3'
is a lot easier to read and understand what's going on by immediately
looking at it.
 
As an added bonus, it'll definitely work ;)
 
 
  


Re: [PHP] Replace in a string with regex

2009-07-22 Thread Kyle Smith
The first match inside () is assigned to $1, the second is assigned to 
$2, and so on.


rszeus wrote:
Hi, 
It doens't work.

I get 0_main.jpg if I do that..
I don't undestand the point of $1 $2 and $3..
In preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', what will be $1 and $2 
and $3 ?
$ " I already knwo it's the (.+?) but the others didnt' get it.

Thank you...

-Mensagem original-
De: Eddie Drapkin [mailto:oorza...@gmail.com] 
Enviada: quarta-feira, 22 de Julho de 2009 16:03

Para: a...@ashleysheridan.co.uk
Cc: Jim Lucas; rszeus; php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex

On Wed, Jul 22, 2009 at 11:01 AM, Ashley
Sheridan wrote:
  

On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote:


rszeus wrote:
  

Thank you.

What about instead test i want to insert a variable ?
Like
$id = "30";
$file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file);


Sure that can be done.  But you will need to change the second argument
to have double quotes so it will be parsed by PHP.

Then I would surround YOUR variable with curly brackets to separate it
from the rest.

echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#',
  "$1{$id}$3",
  $file);

  

I am confusing " and '.

Thank you


-Mensagem original-
De: Eddie Drapkin [mailto:oorza...@gmail.com]
Enviada: quarta-feira, 22 de Julho de 2009 14:12
Para: rszeus
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex

On Wed, Jul 22, 2009 at 9:07 AM, rszeus wrote:


Hi. It Works to remove the _1 but it doesn't replace 
'7a45gfdi6icpan1jtb1j99o925' for 'test'

Thank you

-Mensagem original-
De: Eddie Drapkin [mailto:oorza...@gmail.com]
Enviada: quarta-feira, 22 de Julho de 2009 13:11
Para: rszeus
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex

On Wed, Jul 22, 2009 at 8:02 AM, rszeus wrote:
  

Hello,

I’m tryng to make some replacements on a string.

Everything goês fine until the regular expression.



$file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";

echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
'temp/',’_([0-9])’), array(“test”,"",””), $file)



The idea is to remove /temp and the last _1 from the file name..but i’m only
getting this:

screens/test_1_main.jpg



I want it to be: screens/test_main.jpg



Thank you






If you're trying to do a regular expression based search and replace,
you probably ought to use preg_replace instead of str_replace, as
str_replace doesn't parse regular expressions.

Try this one out, I think I got what you wanted to do:

  

In the second parameter, $2 is the string you'd want to replace to
test so change '$1$2$3' to '$1test$3'.

It seems like you're having trouble with regular expressions, may I
suggest you read up on them?

http://www.regular-expressions.info/ is a pretty great free resource,
as ridiculous as the design is.





  

I tested this, with the double quotes and the curly braces around the
middle argument (to avoid PHP getting confused) and it didn't recognise
the matches by the numbered $1, $3, etc. I know I'm not the op who asked
the original question, but it might help him/her?

Thanks
Ash
www.ashleysheridan.co.uk





To avoid confusion, rather than something like
"$1{$id}$3"
Which looks really indecipherable, I'd definitely think something like
'$1' . $id . '$3'
is a lot easier to read and understand what's going on by immediately
looking at it.

As an added bonus, it'll definitely work ;)


  


RE: [PHP] Replace in a string with regex

2009-07-22 Thread rszeus
Hi, 
It doens't work.
I get 0_main.jpg if I do that..
I don't undestand the point of $1 $2 and $3..
In preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', what will be $1 and $2 
and $3 ?
$ " I already knwo it's the (.+?) but the others didnt' get it.

Thank you...

-Mensagem original-
De: Eddie Drapkin [mailto:oorza...@gmail.com] 
Enviada: quarta-feira, 22 de Julho de 2009 16:03
Para: a...@ashleysheridan.co.uk
Cc: Jim Lucas; rszeus; php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex

On Wed, Jul 22, 2009 at 11:01 AM, Ashley
Sheridan wrote:
> On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote:
>> rszeus wrote:
>> > Thank you.
>> >
>> > What about instead test i want to insert a variable ?
>> > Like
>> > $id = "30";
>> > $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>> > echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', 
>> > $file);
>>
>> Sure that can be done.  But you will need to change the second argument
>> to have double quotes so it will be parsed by PHP.
>>
>> Then I would surround YOUR variable with curly brackets to separate it
>> from the rest.
>>
>> echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#',
>>   "$1{$id}$3",
>>   $file);
>>
>> > I am confusing " and '.
>> >
>> > Thank you
>> >
>> >
>> > -Mensagem original-
>> > De: Eddie Drapkin [mailto:oorza...@gmail.com]
>> > Enviada: quarta-feira, 22 de Julho de 2009 14:12
>> > Para: rszeus
>> > Cc: php-general@lists.php.net
>> > Assunto: Re: [PHP] Replace in a string with regex
>> >
>> > On Wed, Jul 22, 2009 at 9:07 AM, rszeus wrote:
>> >> Hi. It Works to remove the _1 but it doesn't replace 
>> >> '7a45gfdi6icpan1jtb1j99o925' for 'test'
>> >>
>> >> Thank you
>> >>
>> >> -Mensagem original-
>> >> De: Eddie Drapkin [mailto:oorza...@gmail.com]
>> >> Enviada: quarta-feira, 22 de Julho de 2009 13:11
>> >> Para: rszeus
>> >> Cc: php-general@lists.php.net
>> >> Assunto: Re: [PHP] Replace in a string with regex
>> >>
>> >> On Wed, Jul 22, 2009 at 8:02 AM, rszeus wrote:
>> >>> Hello,
>> >>>
>> >>> I’m tryng to make some replacements on a string.
>> >>>
>> >>> Everything goês fine until the regular expression.
>> >>>
>> >>>
>> >>>
>> >>> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>> >>>
>> >>> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
>> >>> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
>> >>>
>> >>>
>> >>>
>> >>> The idea is to remove /temp and the last _1 from the file name..but i’m 
>> >>> only
>> >>> getting this:
>> >>>
>> >>> screens/test_1_main.jpg
>> >>>
>> >>>
>> >>>
>> >>> I want it to be: screens/test_main.jpg
>> >>>
>> >>>
>> >>>
>> >>> Thank you
>> >>>
>> >>>
>> >>>
>> >>>
>> >> If you're trying to do a regular expression based search and replace,
>> >> you probably ought to use preg_replace instead of str_replace, as
>> >> str_replace doesn't parse regular expressions.
>> >>
>> >> Try this one out, I think I got what you wanted to do:
>> >>
>> >> > >>
>> >> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>> >>
>> >> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', 
>> >> $file);
>> >>
>> >>
>> >
>> > In the second parameter, $2 is the string you'd want to replace to
>> > test so change '$1$2$3' to '$1test$3'.
>> >
>> > It seems like you're having trouble with regular expressions, may I
>> > suggest you read up on them?
>> >
>> > http://www.regular-expressions.info/ is a pretty great free resource,
>> > as ridiculous as the design is.
>> >
>> >
>>
>>
>>
> I tested this, with the double quotes and the curly braces around the
> middle argument (to avoid PHP getting confused) and it didn't recognise
> the matches by the numbered $1, $3, etc. I know I'm not the op who asked
> the original question, but it might help him/her?
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>

To avoid confusion, rather than something like
"$1{$id}$3"
Which looks really indecipherable, I'd definitely think something like
'$1' . $id . '$3'
is a lot easier to read and understand what's going on by immediately
looking at it.

As an added bonus, it'll definitely work ;)


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



Re: [PHP] Replace in a string with regex

2009-07-22 Thread Andrew Ballard
On Wed, Jul 22, 2009 at 11:01 AM, Ashley
Sheridan wrote:
> On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote:
>> Sure that can be done.  But you will need to change the second argument
>> to have double quotes so it will be parsed by PHP.
>>
>> Then I would surround YOUR variable with curly brackets to separate it
>> from the rest.
>>
>> echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#',
>>                   "$1{$id}$3",
>>                   $file);
>>
> I tested this, with the double quotes and the curly braces around the
> middle argument (to avoid PHP getting confused) and it didn't recognise
> the matches by the numbered $1, $3, etc. I know I'm not the op who asked
> the original question, but it might help him/her?
>
> Thanks
> Ash
> www.ashleysheridan.co.uk

Don't you also have to escape the $'s for the matches since it's in
double quotes?

"\$1{$id}\$3"

Andrew

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



Re: [PHP] Replace in a string with regex

2009-07-22 Thread Eddie Drapkin
On Wed, Jul 22, 2009 at 11:01 AM, Ashley
Sheridan wrote:
> On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote:
>> rszeus wrote:
>> > Thank you.
>> >
>> > What about instead test i want to insert a variable ?
>> > Like
>> > $id = "30";
>> > $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>> > echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', 
>> > $file);
>>
>> Sure that can be done.  But you will need to change the second argument
>> to have double quotes so it will be parsed by PHP.
>>
>> Then I would surround YOUR variable with curly brackets to separate it
>> from the rest.
>>
>> echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#',
>>                   "$1{$id}$3",
>>                   $file);
>>
>> > I am confusing " and '.
>> >
>> > Thank you
>> >
>> >
>> > -Mensagem original-
>> > De: Eddie Drapkin [mailto:oorza...@gmail.com]
>> > Enviada: quarta-feira, 22 de Julho de 2009 14:12
>> > Para: rszeus
>> > Cc: php-general@lists.php.net
>> > Assunto: Re: [PHP] Replace in a string with regex
>> >
>> > On Wed, Jul 22, 2009 at 9:07 AM, rszeus wrote:
>> >> Hi. It Works to remove the _1 but it doesn't replace 
>> >> '7a45gfdi6icpan1jtb1j99o925' for 'test'
>> >>
>> >> Thank you
>> >>
>> >> -Mensagem original-
>> >> De: Eddie Drapkin [mailto:oorza...@gmail.com]
>> >> Enviada: quarta-feira, 22 de Julho de 2009 13:11
>> >> Para: rszeus
>> >> Cc: php-general@lists.php.net
>> >> Assunto: Re: [PHP] Replace in a string with regex
>> >>
>> >> On Wed, Jul 22, 2009 at 8:02 AM, rszeus wrote:
>> >>> Hello,
>> >>>
>> >>> I’m tryng to make some replacements on a string.
>> >>>
>> >>> Everything goês fine until the regular expression.
>> >>>
>> >>>
>> >>>
>> >>> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>> >>>
>> >>> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
>> >>> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
>> >>>
>> >>>
>> >>>
>> >>> The idea is to remove /temp and the last _1 from the file name..but i’m 
>> >>> only
>> >>> getting this:
>> >>>
>> >>> screens/test_1_main.jpg
>> >>>
>> >>>
>> >>>
>> >>> I want it to be: screens/test_main.jpg
>> >>>
>> >>>
>> >>>
>> >>> Thank you
>> >>>
>> >>>
>> >>>
>> >>>
>> >> If you're trying to do a regular expression based search and replace,
>> >> you probably ought to use preg_replace instead of str_replace, as
>> >> str_replace doesn't parse regular expressions.
>> >>
>> >> Try this one out, I think I got what you wanted to do:
>> >>
>> >> > >>
>> >> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>> >>
>> >> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', 
>> >> $file);
>> >>
>> >>
>> >
>> > In the second parameter, $2 is the string you'd want to replace to
>> > test so change '$1$2$3' to '$1test$3'.
>> >
>> > It seems like you're having trouble with regular expressions, may I
>> > suggest you read up on them?
>> >
>> > http://www.regular-expressions.info/ is a pretty great free resource,
>> > as ridiculous as the design is.
>> >
>> >
>>
>>
>>
> I tested this, with the double quotes and the curly braces around the
> middle argument (to avoid PHP getting confused) and it didn't recognise
> the matches by the numbered $1, $3, etc. I know I'm not the op who asked
> the original question, but it might help him/her?
>
> Thanks
> Ash
> www.ashleysheridan.co.uk
>
>

To avoid confusion, rather than something like
"$1{$id}$3"
Which looks really indecipherable, I'd definitely think something like
'$1' . $id . '$3'
is a lot easier to read and understand what's going on by immediately
looking at it.

As an added bonus, it'll definitely work ;)

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



Re: [PHP] Replace in a string with regex

2009-07-22 Thread Ashley Sheridan
On Wed, 2009-07-22 at 07:54 -0700, Jim Lucas wrote:
> rszeus wrote:
> > Thank you.
> > 
> > What about instead test i want to insert a variable ?
> > Like 
> > $id = "30";
> > $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
> > echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file);
> 
> Sure that can be done.  But you will need to change the second argument
> to have double quotes so it will be parsed by PHP.
> 
> Then I would surround YOUR variable with curly brackets to separate it
> from the rest.
> 
> echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#',
>   "$1{$id}$3",
>   $file);
> 
> > I am confusing " and '. 
> > 
> > Thank you
> >  
> > 
> > -Mensagem original-
> > De: Eddie Drapkin [mailto:oorza...@gmail.com] 
> > Enviada: quarta-feira, 22 de Julho de 2009 14:12
> > Para: rszeus
> > Cc: php-general@lists.php.net
> > Assunto: Re: [PHP] Replace in a string with regex
> > 
> > On Wed, Jul 22, 2009 at 9:07 AM, rszeus wrote:
> >> Hi. It Works to remove the _1 but it doesn't replace 
> >> '7a45gfdi6icpan1jtb1j99o925' for 'test'
> >>
> >> Thank you
> >>
> >> -Mensagem original-
> >> De: Eddie Drapkin [mailto:oorza...@gmail.com]
> >> Enviada: quarta-feira, 22 de Julho de 2009 13:11
> >> Para: rszeus
> >> Cc: php-general@lists.php.net
> >> Assunto: Re: [PHP] Replace in a string with regex
> >>
> >> On Wed, Jul 22, 2009 at 8:02 AM, rszeus wrote:
> >>> Hello,
> >>>
> >>> I’m tryng to make some replacements on a string.
> >>>
> >>> Everything goês fine until the regular expression.
> >>>
> >>>
> >>>
> >>> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
> >>>
> >>> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
> >>> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
> >>>
> >>>
> >>>
> >>> The idea is to remove /temp and the last _1 from the file name..but i’m 
> >>> only
> >>> getting this:
> >>>
> >>> screens/test_1_main.jpg
> >>>
> >>>
> >>>
> >>> I want it to be: screens/test_main.jpg
> >>>
> >>>
> >>>
> >>> Thank you
> >>>
> >>>
> >>>
> >>>
> >> If you're trying to do a regular expression based search and replace,
> >> you probably ought to use preg_replace instead of str_replace, as
> >> str_replace doesn't parse regular expressions.
> >>
> >> Try this one out, I think I got what you wanted to do:
> >>
> >>  >>
> >> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
> >>
> >> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file);
> >>
> >>
> > 
> > In the second parameter, $2 is the string you'd want to replace to
> > test so change '$1$2$3' to '$1test$3'.
> > 
> > It seems like you're having trouble with regular expressions, may I
> > suggest you read up on them?
> > 
> > http://www.regular-expressions.info/ is a pretty great free resource,
> > as ridiculous as the design is.
> > 
> > 
> 
> 
> 
I tested this, with the double quotes and the curly braces around the
middle argument (to avoid PHP getting confused) and it didn't recognise
the matches by the numbered $1, $3, etc. I know I'm not the op who asked
the original question, but it might help him/her?

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Replace in a string with regex

2009-07-22 Thread Jim Lucas
rszeus wrote:
> Thank you.
> 
> What about instead test i want to insert a variable ?
> Like 
> $id = "30";
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file);

Sure that can be done.  But you will need to change the second argument
to have double quotes so it will be parsed by PHP.

Then I would surround YOUR variable with curly brackets to separate it
from the rest.

echo preg_replace('#(screens/)temp/.+?_1(_main\.jpg)#',
  "$1{$id}$3",
  $file);

> I am confusing " and '. 
> 
> Thank you
>  
> 
> -Mensagem original-
> De: Eddie Drapkin [mailto:oorza...@gmail.com] 
> Enviada: quarta-feira, 22 de Julho de 2009 14:12
> Para: rszeus
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
> 
> On Wed, Jul 22, 2009 at 9:07 AM, rszeus wrote:
>> Hi. It Works to remove the _1 but it doesn't replace 
>> '7a45gfdi6icpan1jtb1j99o925' for 'test'
>>
>> Thank you
>>
>> -Mensagem original-
>> De: Eddie Drapkin [mailto:oorza...@gmail.com]
>> Enviada: quarta-feira, 22 de Julho de 2009 13:11
>> Para: rszeus
>> Cc: php-general@lists.php.net
>> Assunto: Re: [PHP] Replace in a string with regex
>>
>> On Wed, Jul 22, 2009 at 8:02 AM, rszeus wrote:
>>> Hello,
>>>
>>> I’m tryng to make some replacements on a string.
>>>
>>> Everything goês fine until the regular expression.
>>>
>>>
>>>
>>> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>>>
>>> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
>>> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
>>>
>>>
>>>
>>> The idea is to remove /temp and the last _1 from the file name..but i’m only
>>> getting this:
>>>
>>> screens/test_1_main.jpg
>>>
>>>
>>>
>>> I want it to be: screens/test_main.jpg
>>>
>>>
>>>
>>> Thank you
>>>
>>>
>>>
>>>
>> If you're trying to do a regular expression based search and replace,
>> you probably ought to use preg_replace instead of str_replace, as
>> str_replace doesn't parse regular expressions.
>>
>> Try this one out, I think I got what you wanted to do:
>>
>> >
>> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>>
>> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file);
>>
>>
> 
> In the second parameter, $2 is the string you'd want to replace to
> test so change '$1$2$3' to '$1test$3'.
> 
> It seems like you're having trouble with regular expressions, may I
> suggest you read up on them?
> 
> http://www.regular-expressions.info/ is a pretty great free resource,
> as ridiculous as the design is.
> 
> 



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



RE: [PHP] Replace in a string with regex

2009-07-22 Thread rszeus

Thank you.

What about instead test i want to insert a variable ?
Like 
$id = "30";
$file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$id$3', $file);
I am confusing " and '. 

Thank you
 

-Mensagem original-
De: Eddie Drapkin [mailto:oorza...@gmail.com] 
Enviada: quarta-feira, 22 de Julho de 2009 14:12
Para: rszeus
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex

On Wed, Jul 22, 2009 at 9:07 AM, rszeus wrote:
> Hi. It Works to remove the _1 but it doesn't replace 
> '7a45gfdi6icpan1jtb1j99o925' for 'test'
>
> Thank you
>
> -Mensagem original-
> De: Eddie Drapkin [mailto:oorza...@gmail.com]
> Enviada: quarta-feira, 22 de Julho de 2009 13:11
> Para: rszeus
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
>
> On Wed, Jul 22, 2009 at 8:02 AM, rszeus wrote:
>> Hello,
>>
>> I’m tryng to make some replacements on a string.
>>
>> Everything goês fine until the regular expression.
>>
>>
>>
>> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>>
>> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
>> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
>>
>>
>>
>> The idea is to remove /temp and the last _1 from the file name..but i’m only
>> getting this:
>>
>> screens/test_1_main.jpg
>>
>>
>>
>> I want it to be: screens/test_main.jpg
>>
>>
>>
>> Thank you
>>
>>
>>
>>
>
> If you're trying to do a regular expression based search and replace,
> you probably ought to use preg_replace instead of str_replace, as
> str_replace doesn't parse regular expressions.
>
> Try this one out, I think I got what you wanted to do:
>
> 
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>
> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file);
>
>

In the second parameter, $2 is the string you'd want to replace to
test so change '$1$2$3' to '$1test$3'.

It seems like you're having trouble with regular expressions, may I
suggest you read up on them?

http://www.regular-expressions.info/ is a pretty great free resource,
as ridiculous as the design is.


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



Re: [PHP] Replace in a string with regex

2009-07-22 Thread Robert Cummings
You can disregard this, it's wrong (I missed a part of the requirements 
:) and there's other solutions already provided (my email client is 
weird when you switch to a folder it always displays the first entry as 
the last read, so sometimes I miss that there are new posts above... I 
just switched a few weeks ago.


Cheers,
Rob.


Robert Cummings wrote:

rszeus wrote:

Hello,

I’m tryng to make some replacements on a string.

Everything goês fine until the regular expression.

 


$file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";

echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
'temp/',’_([0-9])’), array(“test”,"",””), $file)

 


The idea is to remove /temp and the last _1 from the file name..but i’m only
getting this:

screens/test_1_main.jpg

 


I want it to be: screens/test_main.jpg


Sometimes it's helpful to break a problem into smaller problems:



Cheers,
Rob.


--
http://www.interjinn.com
Application and Templating Framework for PHP

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



Re: [PHP] Replace in a string with regex

2009-07-22 Thread Robert Cummings

rszeus wrote:

Hello,

I’m tryng to make some replacements on a string.

Everything goês fine until the regular expression.

 


$file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";

echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
'temp/',’_([0-9])’), array(“test”,"",””), $file)

 


The idea is to remove /temp and the last _1 from the file name..but i’m only
getting this:

screens/test_1_main.jpg

 


I want it to be: screens/test_main.jpg


Sometimes it's helpful to break a problem into smaller problems:



Cheers,
Rob.
--
http://www.interjinn.com
Application and Templating Framework for PHP

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



RE: [PHP] Replace in a string with regex

2009-07-22 Thread rszeus
Totally right on the corrections. Sorry, i did not copy paste from the source 
code, I wrote here to change to other names and wrote it bad.
It should be:
$file = 'screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg';

 echo $a =  str_replace(array('7a45gfdi6icpan1jtb1j99o925', 
'temp/',’_([0-9])’), array('test','',''), $file)

Already understand that str_replace doesn't work with regex, but not getting 
any luck making one preg_replace() to my needs.

Thank you

-Mensagem original-
De: Ashley Sheridan [mailto:a...@ashleysheridan.co.uk] 
Enviada: quarta-feira, 22 de Julho de 2009 13:20
Para: rszeus
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex

On Wed, 2009-07-22 at 13:02 +0100, rszeus wrote:
> Hello,
> 
> I’m tryng to make some replacements on a string.
> 
> Everything goês fine until the regular expression.
> 
>  
> 
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
> 
> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
> 
>  
> 
> The idea is to remove /temp and the last _1 from the file name..but i’m only
> getting this:
> 
> screens/test_1_main.jpg
> 
>  
> 
> I want it to be: screens/test_main.jpg
> 
>  
> 
> Thank you
> 
>  
> 
Well, you seem to have some problems with the syntax you're using on
str_replace(). According to your script, you want to remove the
following:

7a45gfdi6icpan1jtb1j99o925- which you haven't even enclosed in quote
marks
'temp/'
’_([0-9])’- which are using weird back ticks, not quote marks

and you are trying to replace those three things with

“test”  - again, not proper quote marks
""
””  - not proper quote marks

Afaik, str_replace() doesn't allow for text replacement using regular
expressions, for that you'd have to use something like preg_replace()

Also, make sure your strings are correctly enclosed in quote marks, and
that the quote marks you use are actual quote marks and not the accented
'pretty' ones that are offered up by word processors, etc.

A regex which would do the job would look something like this:

^([^/]+)[^_]+\/(.+)$

That should create 2 matches, one for the initial directory and the
other for the latter part of the filename.

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Replace in a string with regex

2009-07-22 Thread Eddie Drapkin
On Wed, Jul 22, 2009 at 9:07 AM, rszeus wrote:
> Hi. It Works to remove the _1 but it doesn't replace 
> '7a45gfdi6icpan1jtb1j99o925' for 'test'
>
> Thank you
>
> -Mensagem original-
> De: Eddie Drapkin [mailto:oorza...@gmail.com]
> Enviada: quarta-feira, 22 de Julho de 2009 13:11
> Para: rszeus
> Cc: php-general@lists.php.net
> Assunto: Re: [PHP] Replace in a string with regex
>
> On Wed, Jul 22, 2009 at 8:02 AM, rszeus wrote:
>> Hello,
>>
>> I’m tryng to make some replacements on a string.
>>
>> Everything goês fine until the regular expression.
>>
>>
>>
>> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>>
>> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
>> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
>>
>>
>>
>> The idea is to remove /temp and the last _1 from the file name..but i’m only
>> getting this:
>>
>> screens/test_1_main.jpg
>>
>>
>>
>> I want it to be: screens/test_main.jpg
>>
>>
>>
>> Thank you
>>
>>
>>
>>
>
> If you're trying to do a regular expression based search and replace,
> you probably ought to use preg_replace instead of str_replace, as
> str_replace doesn't parse regular expressions.
>
> Try this one out, I think I got what you wanted to do:
>
> 
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>
> echo preg_replace('#(screens/)temp/(.+?)_1(_main\.jpg)#', '$1$2$3', $file);
>
>

In the second parameter, $2 is the string you'd want to replace to
test so change '$1$2$3' to '$1test$3'.

It seems like you're having trouble with regular expressions, may I
suggest you read up on them?

http://www.regular-expressions.info/ is a pretty great free resource,
as ridiculous as the design is.

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



RE: [PHP] Replace in a string with regex

2009-07-22 Thread rszeus
Hi. It Works to remove the _1 but it doesn't replace 
'7a45gfdi6icpan1jtb1j99o925' for 'test'

Thank you

-Mensagem original-
De: Eddie Drapkin [mailto:oorza...@gmail.com] 
Enviada: quarta-feira, 22 de Julho de 2009 13:11
Para: rszeus
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Replace in a string with regex

On Wed, Jul 22, 2009 at 8:02 AM, rszeus wrote:
> Hello,
>
> I’m tryng to make some replacements on a string.
>
> Everything goês fine until the regular expression.
>
>
>
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>
> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
>
>
>
> The idea is to remove /temp and the last _1 from the file name..but i’m only
> getting this:
>
> screens/test_1_main.jpg
>
>
>
> I want it to be: screens/test_main.jpg
>
>
>
> Thank you
>
>
>
>

If you're trying to do a regular expression based search and replace,
you probably ought to use preg_replace instead of str_replace, as
str_replace doesn't parse regular expressions.

Try this one out, I think I got what you wanted to do:

http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Replace in a string with regex

2009-07-22 Thread Ashley Sheridan
On Wed, 2009-07-22 at 13:02 +0100, rszeus wrote:
> Hello,
> 
> I’m tryng to make some replacements on a string.
> 
> Everything goês fine until the regular expression.
> 
>  
> 
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
> 
> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
> 
>  
> 
> The idea is to remove /temp and the last _1 from the file name..but i’m only
> getting this:
> 
> screens/test_1_main.jpg
> 
>  
> 
> I want it to be: screens/test_main.jpg
> 
>  
> 
> Thank you
> 
>  
> 
Well, you seem to have some problems with the syntax you're using on
str_replace(). According to your script, you want to remove the
following:

7a45gfdi6icpan1jtb1j99o925- which you haven't even enclosed in quote
marks
'temp/'
’_([0-9])’- which are using weird back ticks, not quote marks

and you are trying to replace those three things with

“test”  - again, not proper quote marks
""
””  - not proper quote marks

Afaik, str_replace() doesn't allow for text replacement using regular
expressions, for that you'd have to use something like preg_replace()

Also, make sure your strings are correctly enclosed in quote marks, and
that the quote marks you use are actual quote marks and not the accented
'pretty' ones that are offered up by word processors, etc.

A regex which would do the job would look something like this:

^([^/]+)[^_]+\/(.+)$

That should create 2 matches, one for the initial directory and the
other for the latter part of the filename.

Thanks
Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Replace in a string with regex

2009-07-22 Thread Eddie Drapkin
On Wed, Jul 22, 2009 at 8:02 AM, rszeus wrote:
> Hello,
>
> I’m tryng to make some replacements on a string.
>
> Everything goês fine until the regular expression.
>
>
>
> $file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";
>
> echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
> 'temp/',’_([0-9])’), array(“test”,"",””), $file)
>
>
>
> The idea is to remove /temp and the last _1 from the file name..but i’m only
> getting this:
>
> screens/test_1_main.jpg
>
>
>
> I want it to be: screens/test_main.jpg
>
>
>
> Thank you
>
>
>
>

If you're trying to do a regular expression based search and replace,
you probably ought to use preg_replace instead of str_replace, as
str_replace doesn't parse regular expressions.

Try this one out, I think I got what you wanted to do:

http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Replace in a string with regex

2009-07-22 Thread rszeus
Hello,

I’m tryng to make some replacements on a string.

Everything goês fine until the regular expression.

 

$file = "screens/temp/7a45gfdi6icpan1jtb1j99o925_1_main.jpg";

echo $a =  str_replace(array(7a45gfdi6icpan1jtb1j99o925,
'temp/',’_([0-9])’), array(“test”,"",””), $file)

 

The idea is to remove /temp and the last _1 from the file name..but i’m only
getting this:

screens/test_1_main.jpg

 

I want it to be: screens/test_main.jpg

 

Thank you

 



Re: [PHP] Replace/Update record in dbase using dbase_replace_record()

2007-07-02 Thread Jochem Maas
Rahul Sitaram Johari wrote:
> Ave,
> 
> Can¹t figure this one out. I¹m using the dbase_replace_record() function to
> replace a record in a dbase (.dbf) database. I just want to replace the
> value of one of the fields with another value. This is my code:
> 
> $db = dbase_open("CRUMBS.DBF", 2) or die("Fatal Error: Could not open
> database!");
> if ($db) {
>   $record_numbers = dbase_numrecords($db);
>   for ($i = 1; $i <= $record_numbers; $i++) {
>  $row = dbase_get_record_with_names($db, $i);
>  if ($row['PHONE'] == $thekey) {
>   print_r($row);
>   $row['A'] == "F";
>   dbase_replace_record($db, $row, 1);
> }
>   }
> }
> dbase_close($db);
> 
> Basically I have a database called ³CRUMBS.DBF², and the record where PHONE
> = $thekey, I want to replace the value of the field ³A² with ³F². I keep
> getting the error: ³Wrong number of fields specified².
> I have over 60 fields in each row ­ and I just want to replace the value of
> the field ³A². 
> 
> Any suggestions?

get a big jar of 'clue'. as in learn to investigate and read ...

not having ever used these functions here are my hypotheses based on 5 seconds 
of
investigation and reading:

1. dbase_get_record_with_names() gives a assoc. array - it may also have
fields as indexed items in that array (like other DB extensions often do) ergo 
double
the fields that you want.

2. quoting the following page: http://php.net/dbase_get_record_with_names

"Return Values
An associative array with the record. This will also include a key named 
deleted which is set to 1 if the record has
been marked for deletion"

so dbase_replace_record() is possibly seeing 'deleted' as a extra erranous 
field.

3. maybe looking at and comparing the output of print_r($row), 
dbase_get_record_with_names($db, $i)
and dbase_get_record($db, $i) might tell you something;

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



[PHP] Replace/Update record in dbase using dbase_replace_record()

2007-07-02 Thread Rahul Sitaram Johari

Ave,

Can¹t figure this one out. I¹m using the dbase_replace_record() function to
replace a record in a dbase (.dbf) database. I just want to replace the
value of one of the fields with another value. This is my code:

$db = dbase_open("CRUMBS.DBF", 2) or die("Fatal Error: Could not open
database!");
if ($db) {
  $record_numbers = dbase_numrecords($db);
  for ($i = 1; $i <= $record_numbers; $i++) {
 $row = dbase_get_record_with_names($db, $i);
 if ($row['PHONE'] == $thekey) {
  print_r($row);
  $row['A'] == "F";
  dbase_replace_record($db, $row, 1);
}
  }
}
dbase_close($db);

Basically I have a database called ³CRUMBS.DBF², and the record where PHONE
= $thekey, I want to replace the value of the field ³A² with ³F². I keep
getting the error: ³Wrong number of fields specified².
I have over 60 fields in each row ­ and I just want to replace the value of
the field ³A². 

Any suggestions?

~~~
Rahul Sitaram Johari
CEO, Twenty Four Seventy Nine Inc.

W: http://www.rahulsjohari.com
E: [EMAIL PROTECTED]

³I morti non sono piu soli ... The dead are no longer lonely²



Re: [PHP] replace single and double quotes

2006-08-30 Thread Jochem Maas
Rafael Mora wrote:
> Hi!
> 
> i want to send a file or output stream in a .php, but first compress it, I
> tryed the example to compress files but how do i do to send as answer to
> the
> http request??

trye the other example


> 
> Rafa
> 

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



Re: [PHP] replace single and double quotes

2006-08-29 Thread Rafael Mora

Hi!

i want to send a file or output stream in a .php, but first compress it, I
tryed the example to compress files but how do i do to send as answer to the
http request??

Rafa


RE: [PHP] replace single and double quotes

2006-08-29 Thread tedd

At 5:04 PM +0200 8/29/06, Reinhart Viane wrote:

About the language remark:
I believe you try to say I need to find a way that the client can add 25
languages without me having to change the database layout or the coding?
Well I can assure you this will not be the fact. The client only needs these
two languages but maybe I should look into it anyway


Depends upon what's in the dB -- if it's language specific, then 
you'll have to change it. If it's not, then you won't.


For what it's worth, the language independent code that I've written 
in the past used constants for language specific labels. From there, 
I would program using English for my code, but those constants could 
be changed by a single setting allowing them to be their language 
counterparts. Food for thought.



About SQl injection:
I must say this is very interesting.
I always wondered what are does and donts when inserting data from a form
into a database and how to check someone did not enter any php code.
Besides the google lookup is there maybe an site or paper dedicated to this?


There are different types of injection. I recommend Essential PHP 
Security by Shifiett:




Well worth the money.

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



RE: [PHP] replace single and double quotes

2006-08-29 Thread Peter Lauri
It might be bad database design yes, however, it all depends on what he is
trying to do. I do it your way Jochem (normalizing the database), but in
some cases the budget to do that might not be big enough. If the client
gives you a task and an budget, normalizing the database might be a "waste"
of time.

I do recommend he should do some reading about SQL injection, phpsec.org is
probably good enough. But to get him going he could just learn that he
should always mysql_real_escape_string on strings, and if he expect integers
to come, use the sprintf and %d.

You can read my blog
http://www.lauri.se/article/4/security-hole-in-golfdatase about a big and
important golf organization in Sweden and how they screwed up about their
security.

Hrm, I might be wrong here :)

/Peter



-Original Message-
From: Jochem Maas [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 29, 2006 8:37 PM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] replace single and double quotes

Reinhart Viane wrote:
> This is the code is use to insert/update text into a database field:
> 
> $sqledit="update activities set act_extra='$_POST[editextra]',
> act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";

this indicates 'bad' database design ... because adding a language involves
having to change the database schema. I personally think that there should
be
no need to change the database schema and/or queries and/or code just
because
the client wants an extra language.

it also indicates that you have a glaring SQL injection problem. what
happens
when I craft a POST request that contains an 'editid' parameter with the
following in it:

'1 OR 1'

or

'1; DELETE * FROM activities'

google 'SQL injection', do some reading and get into the habit of sanitizing
your user input.

> 
> Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
> double quotes.
> So the query almost always gives me an error.
> 
> I know I have to replace " with ", but I do not know how to replace
the

WRONG - you only replace " with " when you OUTPUTTING the string as part
of a
webpage. the database should contain the actual

> single quote so it is shown as a single quote on a webpage when I get it
> from the database

mysql_real_escape_string()

search this archive; there is plenty of discussion about escaping data so
that it
can be inserted into a database (mostly concerning MySQL).

> 
> I have been looking into str_replace and preg_replace. But what I really
> need is a solution that 'replaces' single quotes, double quotes en curly
> quotes so I tackle all possible problems and the same text as it was
inputed
> in the textarea is shown on the webpage.
> 
> Thx in advance
> 

-- 
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] replace single and double quotes

2006-08-29 Thread Jochem Maas
Reinhart Viane wrote:
> About the language remark:
> I believe you try to say I need to find a way that the client can add 25
> languages without me having to change the database layout or the coding?
> Well I can assure you this will not be the fact. The client only needs these
> two languages but maybe I should look into it anyway

it's more a of a theoretical thing. but if the client wants french and flemish
(or dutch) now there is a distinct chance that they will want to add dutch,
english and/or german in the forseeable future... going by my experience of
building multilingual sites for [west] european companies (I have one
client that actually wanted flemish as well as dutch so that they could tailor 
texts
in the flemish pages specifically to [search] terms regularly used in belgium).

your db design may very well be sufficient for this particular case.

> 
> About SQl injection:
> I must say this is very interesting.
> I always wondered what are does and donts when inserting data from a form
> into a database and how to check someone did not enter any php code.
> Besides the google lookup is there maybe an site or paper dedicated to this?

phpsec.org - recommended to read it back to front!

> 
> Thx again, didn't think this question was about to bring up what I was
> looking for in the back of my head
> 
> 
> -Oorspronkelijk bericht-
> Van: Jochem Maas [mailto:[EMAIL PROTECTED] 
> Verzonden: dinsdag 29 augustus 2006 15:37
> Aan: [EMAIL PROTECTED]
> CC: php-general@lists.php.net
> Onderwerp: Re: [PHP] replace single and double quotes
> 
> Reinhart Viane wrote:
>> This is the code is use to insert/update text into a database field:
>>
>> $sqledit="update activities set act_extra='$_POST[editextra]',
>> act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";
> 
> this indicates 'bad' database design ... because adding a language involves
> having to change the database schema. I personally think that there should
> be
> no need to change the database schema and/or queries and/or code just
> because
> the client wants an extra language.
> 
> it also indicates that you have a glaring SQL injection problem. what
> happens
> when I craft a POST request that contains an 'editid' parameter with the
> following in it:
> 
>   '1 OR 1'
> 
> or
> 
>   '1; DELETE * FROM activities'
> 
> google 'SQL injection', do some reading and get into the habit of sanitizing
> your user input.
> 
>> Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
>> double quotes.
>> So the query almost always gives me an error.
>>
>> I know I have to replace " with ", but I do not know how to replace
> the
> 
> WRONG - you only replace " with " when you OUTPUTTING the string as part
> of a
> webpage. the database should contain the actual
> 
>> single quote so it is shown as a single quote on a webpage when I get it
>> from the database
> 
> mysql_real_escape_string()
> 
> search this archive; there is plenty of discussion about escaping data so
> that it
> can be inserted into a database (mostly concerning MySQL).
> 
> 

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



RE: [PHP] replace single and double quotes

2006-08-29 Thread Reinhart Viane
Ok 'ill give this a shot together with the guidelines from jochen.

Thx afan.

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Verzonden: dinsdag 29 augustus 2006 15:28
Aan: [EMAIL PROTECTED]
CC: php-general@lists.php.net
Onderwerp: Re: [PHP] replace single and double quotes

since I had something similar as a problem, let m etry to anser ang see
did I get it correct :)

first, and most important: never store in DB row submitted string

$act_extra = mysql_real_escape_string($_POST[editextra]);
$act_extra_fr = mysql_real_escape_string($_POST[editextrafr])
$act_id = mysql_real_escape_string($_POST[editid]);

then:
$sqledit = "
update activities
set act_extra='".$act_extra."',
act_extra_fr = '".$act_extra_fr."'
where act_id = '".$act_id."'";

to check:
echo $sqledit;

it should work now.

hope this helped.

-afan



> This is the code is use to insert/update text into a database field:
>
> $sqledit="update activities set act_extra='$_POST[editextra]',
> act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";
>
> Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
> double quotes.
> So the query almost always gives me an error.
>
> I know I have to replace " with ", but I do not know how to replace
> the
> single quote so it is shown as a single quote on a webpage when I get it
> from the database
>
> I have been looking into str_replace and preg_replace. But what I really
> need is a solution that 'replaces' single quotes, double quotes en curly
> quotes so I tackle all possible problems and the same text as it was
> inputed
> in the textarea is shown on the webpage.
>
> Thx in advance
>
> --
> 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] replace single and double quotes

2006-08-29 Thread Reinhart Viane
About the language remark:
I believe you try to say I need to find a way that the client can add 25
languages without me having to change the database layout or the coding?
Well I can assure you this will not be the fact. The client only needs these
two languages but maybe I should look into it anyway

About SQl injection:
I must say this is very interesting.
I always wondered what are does and donts when inserting data from a form
into a database and how to check someone did not enter any php code.
Besides the google lookup is there maybe an site or paper dedicated to this?

Thx again, didn't think this question was about to bring up what I was
looking for in the back of my head


-Oorspronkelijk bericht-
Van: Jochem Maas [mailto:[EMAIL PROTECTED] 
Verzonden: dinsdag 29 augustus 2006 15:37
Aan: [EMAIL PROTECTED]
CC: php-general@lists.php.net
Onderwerp: Re: [PHP] replace single and double quotes

Reinhart Viane wrote:
> This is the code is use to insert/update text into a database field:
> 
> $sqledit="update activities set act_extra='$_POST[editextra]',
> act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";

this indicates 'bad' database design ... because adding a language involves
having to change the database schema. I personally think that there should
be
no need to change the database schema and/or queries and/or code just
because
the client wants an extra language.

it also indicates that you have a glaring SQL injection problem. what
happens
when I craft a POST request that contains an 'editid' parameter with the
following in it:

'1 OR 1'

or

'1; DELETE * FROM activities'

google 'SQL injection', do some reading and get into the habit of sanitizing
your user input.

> 
> Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
> double quotes.
> So the query almost always gives me an error.
> 
> I know I have to replace " with ", but I do not know how to replace
the

WRONG - you only replace " with " when you OUTPUTTING the string as part
of a
webpage. the database should contain the actual

> single quote so it is shown as a single quote on a webpage when I get it
> from the database

mysql_real_escape_string()

search this archive; there is plenty of discussion about escaping data so
that it
can be inserted into a database (mostly concerning MySQL).

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



RE: [PHP] replace single and double quotes

2006-08-29 Thread Peter Lauri
Assumning $act_id is integer:

$act_extra = mysql_real_escape_string($_POST[editextra]);
$act_extra_fr = mysql_real_escape_string($_POST[editextrafr])
$act_id = $_POST[editid];

$sql = sprint("UPDATE activities SET act_extra='%s', act_extra_fr='%s' WHERE
act_id=%d", $act_extra, $act_extra_fr, $act_id);

Notice the %d for the id part if $act_id should be integer.

/Peter


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 29, 2006 8:28 PM
To: [EMAIL PROTECTED]
Cc: php-general@lists.php.net
Subject: Re: [PHP] replace single and double quotes

since I had something similar as a problem, let m etry to anser ang see
did I get it correct :)

first, and most important: never store in DB row submitted string

$act_extra = mysql_real_escape_string($_POST[editextra]);
$act_extra_fr = mysql_real_escape_string($_POST[editextrafr])
$act_id = mysql_real_escape_string($_POST[editid]);

then:
$sqledit = "
update activities
set act_extra='".$act_extra."',
act_extra_fr = '".$act_extra_fr."'
where act_id = '".$act_id."'";

to check:
echo $sqledit;

it should work now.

hope this helped.

-afan



> This is the code is use to insert/update text into a database field:
>
> $sqledit="update activities set act_extra='$_POST[editextra]',
> act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";
>
> Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
> double quotes.
> So the query almost always gives me an error.
>
> I know I have to replace " with ", but I do not know how to replace
> the
> single quote so it is shown as a single quote on a webpage when I get it
> from the database
>
> I have been looking into str_replace and preg_replace. But what I really
> need is a solution that 'replaces' single quotes, double quotes en curly
> quotes so I tackle all possible problems and the same text as it was
> inputed
> in the textarea is shown on the webpage.
>
> Thx in advance
>
> --
> 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] replace single and double quotes

2006-08-29 Thread Jochem Maas
Reinhart Viane wrote:
> This is the code is use to insert/update text into a database field:
> 
> $sqledit="update activities set act_extra='$_POST[editextra]',
> act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";

this indicates 'bad' database design ... because adding a language involves
having to change the database schema. I personally think that there should be
no need to change the database schema and/or queries and/or code just because
the client wants an extra language.

it also indicates that you have a glaring SQL injection problem. what happens
when I craft a POST request that contains an 'editid' parameter with the 
following in it:

'1 OR 1'

or

'1; DELETE * FROM activities'

google 'SQL injection', do some reading and get into the habit of sanitizing
your user input.

> 
> Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
> double quotes.
> So the query almost always gives me an error.
> 
> I know I have to replace " with ", but I do not know how to replace the

WRONG - you only replace " with " when you OUTPUTTING the string as part of 
a
webpage. the database should contain the actual

> single quote so it is shown as a single quote on a webpage when I get it
> from the database

mysql_real_escape_string()

search this archive; there is plenty of discussion about escaping data so that 
it
can be inserted into a database (mostly concerning MySQL).

> 
> I have been looking into str_replace and preg_replace. But what I really
> need is a solution that 'replaces' single quotes, double quotes en curly
> quotes so I tackle all possible problems and the same text as it was inputed
> in the textarea is shown on the webpage.
> 
> Thx in advance
> 

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



Re: [PHP] replace single and double quotes

2006-08-29 Thread Jochem Maas
[EMAIL PROTECTED] wrote:
> since I had something similar as a problem, let m etry to anser ang see
> did I get it correct :)

seems ok ...

> 
> first, and most important: never store in DB row submitted string
> 
> $act_extra = mysql_real_escape_string($_POST[editextra]);
> $act_extra_fr = mysql_real_escape_string($_POST[editextrafr])

the following should always be an integer (probably) ...

> $act_id = mysql_real_escape_string($_POST[editid]);

so why not do:

$act_id = intval($_POST[editid]);
if (!$act_id) die('go away script kiddie!');

> 
> then:
> $sqledit = "
> update activities
> set act_extra='".$act_extra."',
> act_extra_fr = '".$act_extra_fr."'
> where act_id = '".$act_id."'";

very minor point - but why not save your eyes a little:

$sqledit = "UPDATE activities
SET act_extra='{$act_extra}',
act_extra_fr='{$act_extra_fr}'
WHERE act_id={$act_id}";

> 
> to check:
> echo $sqledit;
> 
> it should work now.
> 
> hope this helped.
> 
> -afan
> 
> 
> 
>> This is the code is use to insert/update text into a database field:
>>
>> $sqledit="update activities set act_extra='$_POST[editextra]',
>> act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";
>>
>> Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
>> double quotes.
>> So the query almost always gives me an error.
>>
>> I know I have to replace " with ", but I do not know how to replace
>> the
>> single quote so it is shown as a single quote on a webpage when I get it
>> from the database
>>
>> I have been looking into str_replace and preg_replace. But what I really
>> need is a solution that 'replaces' single quotes, double quotes en curly
>> quotes so I tackle all possible problems and the same text as it was
>> inputed
>> in the textarea is shown on the webpage.
>>
>> Thx in advance
>>
>> --
>> 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] replace single and double quotes

2006-08-29 Thread afan
since I had something similar as a problem, let m etry to anser ang see
did I get it correct :)

first, and most important: never store in DB row submitted string

$act_extra = mysql_real_escape_string($_POST[editextra]);
$act_extra_fr = mysql_real_escape_string($_POST[editextrafr])
$act_id = mysql_real_escape_string($_POST[editid]);

then:
$sqledit = "
update activities
set act_extra='".$act_extra."',
act_extra_fr = '".$act_extra_fr."'
where act_id = '".$act_id."'";

to check:
echo $sqledit;

it should work now.

hope this helped.

-afan



> This is the code is use to insert/update text into a database field:
>
> $sqledit="update activities set act_extra='$_POST[editextra]',
> act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";
>
> Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
> double quotes.
> So the query almost always gives me an error.
>
> I know I have to replace " with ", but I do not know how to replace
> the
> single quote so it is shown as a single quote on a webpage when I get it
> from the database
>
> I have been looking into str_replace and preg_replace. But what I really
> need is a solution that 'replaces' single quotes, double quotes en curly
> quotes so I tackle all possible problems and the same text as it was
> inputed
> in the textarea is shown on the webpage.
>
> Thx in advance
>
> --
> 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] replace single and double quotes

2006-08-29 Thread Reinhart Viane
This is the code is use to insert/update text into a database field:

$sqledit="update activities set act_extra='$_POST[editextra]',
act_extra_fr='$_POST[editextrafr]' where act_id=$_POST[editid]";

Now both $_POST[editextra] and $_POST[editextrafr] can contain single or
double quotes.
So the query almost always gives me an error.

I know I have to replace " with ", but I do not know how to replace the
single quote so it is shown as a single quote on a webpage when I get it
from the database

I have been looking into str_replace and preg_replace. But what I really
need is a solution that 'replaces' single quotes, double quotes en curly
quotes so I tackle all possible problems and the same text as it was inputed
in the textarea is shown on the webpage.

Thx in advance

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



Re: [PHP] replace

2005-09-19 Thread tg-php
I hope this is what you were looking for:

$contents = "Numbers 1, 2, 3, 4 and 5 will be replaced with A, B, C, D, and E";
$searcharr =  array("1", "2", "3", "4", "5");
$replacearr = array("A", "B", "C", "D", "E");
$newcontents = str_replace($searcharr, $replacearr, $contents);

echo $newcontents;

Numbers A, B, C, D and E will be replaced with A, B, C, D, and E

Good luck!

-TG

= = = Original message = = =

Hi all

if I have an array of chars to be replaced array(1,2,3,4,5);
and an arry of chars to replace with array(a,b,c,d,e)

what function do I need to replace all chars from one arry to the other that 
are found in the var $contents

Thanks

M 


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



[PHP] replace

2005-09-19 Thread php @ net mines

Hi all

if I have an array of chars to be replaced array(1,2,3,4,5);
and an arry of chars to replace with array(a,b,c,d,e)

what function do I need to replace all chars from one arry to the other that 
are found in the var $contents


Thanks

M 


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



Re: [PHP] replace striing éèêà

2005-06-06 Thread Jochem Maas

John Taylor-Johnston wrote:
Can someone show me how to get rid of international characters in 
$string? Is there a function already made?


the acute/grave accents on the chars are called 'diacritics'

You cannot use accented characters in a name reference : name="montréal">.

I guess this below is a start. Is there a better way?
John

http://ca.php.net/manual/en/function.str-replace.php
$string = "àâéèç";
|$find = array("à", "â", "é", "è", "ç");
||$||replacewith|| = array("a", "a", "e", "e", "c");||
$onlyconsonants = str_replace($vowels, $replacewith, $string);



$base_drop_char_match =   array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '-', 
'~', '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!');
$base_drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '',  '',   ' ', ' ', ' ', ' ', '',  ' ', ' ', '',  ' 
', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , ' ', ' ', ' ', ' ',  ' ', ' ');


$xtr_drop_char_match   = array('à', 'â', 'ä', 'æ', 'è', 'ê', 'ì', 'î', 'ð', 'ò', 'ô', 'ö', 'ø', 'ú', 'ü', 'ß', 'á', 'ã', 
'å', 'ç', 'é', 'ë', 'í', 'ï', 'ñ', 'ó', 'õ', 'ù', 'û', 'ý', 'ÿ');
$xtr_drop_char_replace = array('a', 'a', 'a', 'a', 'e', 'e', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 's', 'a', 'a', 
'a', 'c', 'e', 'e', 'i', 'i', 'n', 'o', 'o', 'u', 'u', 'y', 'y');


$drop_char_match   = array_merge( $base_drop_char_match, $xtr_drop_char_match );
$drop_char_replace = array_merge( $base_drop_char_replace, 
$xtr_drop_char_replace );

return str_replace($drop_char_match, $drop_char_replace, $word);

}

// alternatively


function getUndiacritical2($word)
{

$base_drop_char_match =   array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '-', 
'~', '+', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!');
$base_drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '',  '',   ' ', ' ', ' ', ' ', '',  ' ', ' ', '',  ' 
', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , ' ', ' ', ' ', ' ',  ' ', ' ');


$xtr_drop_char_match   = array('à', 'â', 'ä', 'æ', 'è', 'ê', 'ì', 'î', 'ð', 'ò', 'ô', 'ö', 'ø', 'ú', 'ü', 'ß', 'á', 'ã', 
'å', 'ç', 'é', 'ë', 'í', 'ï', 'ñ', 'ó', 'õ', 'ù', 'û', 'ý', 'ÿ');
$xtr_drop_char_replace = array('a', 'a', 'a', 'a', 'e', 'e', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 's', 'a', 'a', 
'a', 'c', 'e', 'e', 'i', 'i', 'n', 'o', 'o', 'u', 'u', 'y', 'y');


$drop_char_match   = join('',array_merge( $base_drop_char_match, 
$xtr_drop_char_match ));
$drop_char_replace = join('',array_merge( $base_drop_char_replace, 
$xtr_drop_char_replace ));

return strtr($drop_char_match, $drop_char_replace, $word);

}


?>

I doubt either of these funcs is perfect but it hopefully gives you a clue in 
the right
redirection.

rgds,
Jochem



|



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



Re: [PHP] replace striing éèêà

2005-06-05 Thread Chris

Look into strtr()

http://www.php.net/strtr

It seems to be precisely what you want.

John Taylor-Johnston wrote:

Can someone show me how to get rid of international characters in 
$string? Is there a function already made?
You cannot use accented characters in a name reference : name="montréal">.

I guess this below is a start. Is there a better way?
John

http://ca.php.net/manual/en/function.str-replace.php
$string = "àâéèç";
|$find = array("à", "â", "é", "è", "ç");
||$||replacewith|| = array("a", "a", "e", "e", "c");||
$onlyconsonants = str_replace($vowels, $replacewith, $string);

|



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



[PHP] replace striing éèêà

2005-06-05 Thread John Taylor-Johnston
Can someone show me how to get rid of international characters in 
$string? Is there a function already made?
You cannot use accented characters in a name reference : name="montréal">.

I guess this below is a start. Is there a better way?
John

http://ca.php.net/manual/en/function.str-replace.php
$string = "àâéèç";
|$find = array("à", "â", "é", "è", "ç");
||$||replacewith|| = array("a", "a", "e", "e", "c");||
$onlyconsonants = str_replace($vowels, $replacewith, $string);

|

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



Re: [PHP] replace special characters

2005-02-24 Thread Jason Wong
On Thursday 24 February 2005 16:14, Frank Arensmeier wrote:

> 1) replace ".." with a string like "file://server/folder"
> 2) replace all "\" characters with "/".
>
> The PHP code looks something like:
>
> $path_to_file = "..\1 PDF Filer\65051.PDF";

  $path_to_file = '..\1 PDF Filer\65051.PDF';

Don't use double-quoted strings unless you *need* to. Ditto for the rest 
of your code.

> The big problem is the character "\" which, if I got it right, in
> UNICODE is used for things like expressing line breaks ('\n' or
> something like this).

"\n" is a newline character, however it has nothing to do with unicode, 
RTFM for details.

> The code above is resulting in the following 
> error massage: "Parse error: parse error, expecting `')'' in
> /xxx/xxx/xxx/TMPz06yoces6o.php on line 2."

Switch to using a decent syntax highlighting editor and these types of 
errors will be immediately obvious.

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
New Year Resolution: Ignore top posted posts

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




[PHP] replace special characters

2005-02-24 Thread Frank Arensmeier
Hello everybody!
I was wondering if you could help me with a little problem I ran into 
some days ago.

In my database I have some information about file paths. Originally, 
those paths come from a Windows Excel spreadsheet and look like "..\1 
PDF Filer\65051.PDF". In my PHP code I try to do two things:

1) replace ".." with a string like "file://server/folder"
2) replace all "\" characters with "/".
The PHP code looks something like:
$path_to_file = "..\1 PDF Filer\65051.PDF";
$things_to_look_for = array("..", "\");
$things_to_replace_with = array("file://server/folder", "/");
$link = str_replace($things_to_look_for, $things_to_replace_with, 
$path_to_file);

The big problem is the character "\" which, if I got it right, in 
UNICODE is used for things like expressing line breaks ('\n' or 
something like this). The code above is resulting in the following 
error massage: "Parse error: parse error, expecting `')'' in 
/xxx/xxx/xxx/TMPz06yoces6o.php on line 2."

Is there a simple solution for this problem?
Regards,
Frank
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] replace

2005-01-28 Thread Jochem Maas
blackwater dev wrote:
thanks...I will look that up.  Not very good with regular expressions though.
this is your chance to get a bit better. have a go,
if you get stuck post your code :-)
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] replace

2005-01-28 Thread blackwater dev
thanks...I will look that up.  Not very good with regular expressions though.


On Fri, 28 Jan 2005 08:11:59 -0800 (PST), Richard Lynch <[EMAIL PROTECTED]> 
wrote:
> blackwater dev wrote:
> > I have a section of my site that uses HTMLArea to allow the users to
> > manage content.  For one certain section, they want all of their links
> > to pop up in another window.  I know they can use HTMLArea and add
> > this code themselves but they don't want to get to the code side of
> > it.
> >
> > Currently, I just pull out the entire contents and echo them to the
> > screen:
> >
> > echo $sql->getField('content');
> >
> > but now I need to replace each anchor tag from
> > http://www.something.com/";>
> > to
> > http://www.something.com/')">
> >
> > I can easily use str_replace() to replace " > but how do I add the last )?
> 
> http://php.net/preg_replace
> would probably be easiest.
> 
> --
> Like Music?
> http://l-i-e.com/artists.htm
> 
>

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



Re: [PHP] replace

2005-01-28 Thread Richard Lynch
blackwater dev wrote:
> I have a section of my site that uses HTMLArea to allow the users to
> manage content.  For one certain section, they want all of their links
> to pop up in another window.  I know they can use HTMLArea and add
> this code themselves but they don't want to get to the code side of
> it.
>
> Currently, I just pull out the entire contents and echo them to the
> screen:
>
> echo $sql->getField('content');
>
> but now I need to replace each anchor tag from
> http://www.something.com/";>
> to
> http://www.something.com/')">
>
> I can easily use str_replace() to replace " but how do I add the last )?

http://php.net/preg_replace
would probably be easiest.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] replace

2005-01-28 Thread blackwater dev
I have a section of my site that uses HTMLArea to allow the users to
manage content.  For one certain section, they want all of their links
to pop up in another window.  I know they can use HTMLArea and add
this code themselves but they don't want to get to the code side of
it.

Currently, I just pull out the entire contents and echo them to the screen:

echo $sql->getField('content');

but now I need to replace each anchor tag from
http://www.something.com/";>
to
http://www.something.com/')">

I can easily use str_replace() to replace "http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] [Fwd: DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card numberswith X ???)]

2005-01-25 Thread Jordi Canals
On Tue, 25 Jan 2005 16:29:38 -, Chris Ramsay
<[EMAIL PROTECTED]> wrote:
> 
> 
> >Hey!
> >I just got this emai lfrom RIPN mail processor at Moscow ?!?!?!?!?
> 
> 
> 
> I have received this also with both my postings today...and probably will
> again...
> 

I've just sent ONE message to the list today and I've got 8 times this
message ...

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



Re: [PHP] [Fwd: DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card numbers with X ???)]

2005-01-25 Thread John Nichel
Mike Johnson wrote:
From: Richard Davey [mailto:[EMAIL PROTECTED] 


Hello Afan,
Tuesday, January 25, 2005, 4:12:43 PM, you wrote:
AP> Hey!
AP> I just got this emai lfrom RIPN mail processor at Moscow ?!?!?!?!?
Join the club.. everyone who posts gets one. Annoying, no?
Best regards,
Richard Davey

My personal favorite is when someone requests a read receipt on
listmail. I wonder what their inbox looks like when 500 people send one
back all in the space of five minutes.
I usually just delete those without a second glance, but you may be on 
to something...if we all send the read receipt, then maybe the user will 
get tired of all the receipts and turn it off. ;)

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] [Fwd: DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card numberswith X ???)]

2005-01-25 Thread Chris Ramsay


>Hey!
>I just got this emai lfrom RIPN mail processor at Moscow ?!?!?!?!?



I have received this also with both my postings today...and probably will
again...

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



Re: [PHP] [Fwd: DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card numberswith X ???)]

2005-01-25 Thread Richard Davey
Hello Chris,

Tuesday, January 25, 2005, 5:07:37 PM, you wrote:

CR> Maybe that's another thing to add to the [NEWBIE GUIDE] - I would have found
CR> it useful! ;)

Ahh... so you're the Russian mail server? :)

I guess we could add "don't be a twat with your auto-responders" to
the newbie faq, but really no-one ever pays any attention!

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I am not young enough to know everything." - Oscar Wilde

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



[PHP] [Fwd: DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card numberswith X ???)]

2005-01-25 Thread Chris Ramsay

Join the club.. everyone who posts gets one. Annoying, no?


Maybe that's another thing to add to the [NEWBIE GUIDE] - I would have found
it useful! ;)

Chris Ramsay
-
Web Developer - The Danwood Group Ltd.
T: +44 (0) 1522 834482
F: +44 (0) 1522 884488
e: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
w: http://www.danwood.co.uk
-

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



Re: [PHP] [Fwd: DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card numbers with X ???)]

2005-01-25 Thread Afan Pasalic
Not at all... Actually, I enjoy  :-D
I just wonder what's going on and is it problem on my side or... Now I 
breath easier...

;-)
-afan

Richard Davey wrote:
Hello Afan,
Tuesday, January 25, 2005, 4:12:43 PM, you wrote:
AP> Hey!
AP> I just got this emai lfrom RIPN mail processor at Moscow ?!?!?!?!?
Join the club.. everyone who posts gets one. Annoying, no?
Best regards,
Richard Davey
 

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


RE: [PHP] [Fwd: DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card numbers with X ???)]

2005-01-25 Thread Mike Johnson
From: Richard Davey [mailto:[EMAIL PROTECTED] 

> Hello Afan,
> 
> Tuesday, January 25, 2005, 4:12:43 PM, you wrote:
> 
> AP> Hey!
> AP> I just got this emai lfrom RIPN mail processor at Moscow ?!?!?!?!?
> 
> Join the club.. everyone who posts gets one. Annoying, no?
> 
> Best regards,
> 
> Richard Davey

My personal favorite is when someone requests a read receipt on
listmail. I wonder what their inbox looks like when 500 people send one
back all in the space of five minutes.


-- 
Mike Johnson Smarter Living, Inc.
Web Developerwww.smartertravel.com
[EMAIL PROTECTED]   (617) 886-5539

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



RE: [PHP] [Fwd: DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card numberswith X ???)]

2005-01-25 Thread Jay Blanchard
[snip]
I just got this emai lfrom RIPN mail processor at Moscow ?!?!?!?!?

What's going on?
[/snip]

I have been getting it with every send too...off to /dev/null

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



Re: [PHP] [Fwd: DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card numbers with X ???)]

2005-01-25 Thread Richard Davey
Hello Afan,

Tuesday, January 25, 2005, 4:12:43 PM, you wrote:

AP> Hey!
AP> I just got this emai lfrom RIPN mail processor at Moscow ?!?!?!?!?

Join the club.. everyone who posts gets one. Annoying, no?

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 "I am not young enough to know everything." - Oscar Wilde

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



Re: [PHP] Replace credit card numbers with X ???

2005-01-25 Thread Jochem Maas
Jay Blanchard wrote:
[snip]
I need to replace all the numbers of a credit card except for the last
4 with an 'X' ... can't seem to locate the string function for this...
can someone point me in the right direction here to what php item i
should be using.
[/snip]
ROFLMMFAO! It's all been discussed before Joe! 

http://www.php.net/ereg_replace

wtf :-), I can't find any particular mention of his problem on that page
 (and I know how to use the CTRL+f keycombo in firefox, thanks for asking :-).
regardless of whether ereg_replace() would satisfy his needs pointing him at
that page without explaination is a bit stupid - the guy obviously doesn't
have even half a clue with regards to string manipulation - therefore I think
its safe to assume that regexps are a bit out of his league.
but then again if he is working with (_other_peoples_) creditcard numbers
he should probably:
a, know this shit.
or
b, be capable of finding the answer in the manual.
n'est pas?
anyway I had fun remembering exactly what ROFLMMFAO meant :-), and the tinge
of RTFM at Joe was probably justified - and even if it wasn't I condone it :-)
is it fair game to throw someone an RTFM after you have helped them?

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


Re: [PHP] Replace credit card numbers with X ???

2005-01-25 Thread tg-php
In addition to what was mentioned already, using ereg_replace, if you're 
pulling the CC# string out of a database of off of some POST data or something, 
just use a substr() function to pull the last 4 digits and prepend a bunch of 
X's.

$ccnum = "342342522342342";  # fake CC #, prob not even correct # of digits :)
$maskedccnum = "XXX" . substr($ccnum,strlen($ccnum)-5,4);


If you're trying to do it in a form, realtime as the user enters it, you'd have 
to use some funky javascript or do something with a password form type or 
something.  But sounds like you want it like when you display an invoice 
afterwards or display a "Would you like to use this CC that's already on file?" 
type thing without exposing the whole CC#.

-TG

= = = Original message = = =

Hello,

I need to replace all the numbers of a credit card except for the last
4 with an 'X' ... can't seem to locate the string function for this...
can someone point me in the right direction here to what php item i
should be using.

Thanks!
Joe


___
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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



Re: [PHP] Replace credit card numbers with X ???

2005-01-25 Thread Jochem Maas
Joe Harman wrote:
Hello,
I need to replace all the numbers of a credit card except for the last
4 with an 'X' ... can't seem to locate the string function for this...
can someone point me in the right direction here to what php item i
should be using.
that'll be:
string php_replace_all_but_last_four_chars_of_creditcard_number(string input[, 
string pad_string])
actually that func doesn't exist - what you need to do (well its one way to do 
it)
is use a combination of substr() and str_pad() e.g:
echo str_pad(substr($cc, -4), 20, 'X', STR_PAD_LEFT);
where $cc is the previously checked/verified/sanitized creditcard no.
and 20 is the length of a creditcard no. - forgive me if I'm wrong about the CC
number length, I don't have a creditcard.
Thanks!
Joe
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] [Fwd: DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card numbers with X ???)]

2005-01-25 Thread Afan Pasalic
Hey!
I just got this emai lfrom RIPN mail processor at Moscow ?!?!?!?!?
What's going on?
-afan
 Original Message 
Subject: 	DNS.050125191312.29782 (Re: Re: [PHP] Replace credit card 
numbers with X ???)
Date: 	Tue, 25 Jan 2005 19:13:27 +0300
From: 	RIPN NCC <[EMAIL PROTECTED]>
To: 	php-general@lists.php.net,[EMAIL PROTECTED]


Dear Madam/Sir,
Here are results of  processing your  request:
From:Afan Pasalic <[EMAIL PROTECTED]>
Subject: Re: [PHP] Replace credit card numbers with X ???
Date:Tue, 25 Jan 2005 10:06:21 -0600
Msg-Id:  <[EMAIL PROTECTED]>

this is my way.
unrecognized statment - line ignored.
$cc_stars = '';
unrecognized statment - line ignored.
$cc_no_lenght = strlen($cc_number);
unrecognized statment - line ignored.
$cc_info_first4 = substr($cc_number, 0, 4);
unrecognized statment - line ignored.
$cc_info_last4 = substr($cc_number, (strlen($cc_number) - 4), 4);
unrecognized statment - line ignored.
for($i=0; $i<($cc_no_lenght-8); $i++) $cc_stars .= '*';
unrecognized statment - line ignored.
$cc_number = $cc_info_first4 .$cc_stars. $cc_info_last4;
unrecognized statment - line ignored.

-afan
unrecognized statment - line ignored.
Joe Harman wrote:
unrecognized statment - line ignored.
>Hello,
unrecognized statment - line ignored.
>
unrecognized statment - line ignored.
>I need to replace all the numbers of a credit card except for the last
unrecognized statment - line ignored.
>4 with an 'X' ... can't seem to locate the string function for this...
unrecognized statment - line ignored.
>can someone point me in the right direction here to what php item i
unrecognized statment - line ignored.
>should be using.
unrecognized statment - line ignored.
Too many warnings (max. 2) - FATAL ERROR!
>
>Thanks!
>Joe
>
>  
>

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

Your current request counter: 1.
You may send us 119 in this hour.
Thank you,
RIPN mail processor.
Tue Jan 25 19:13:27 MSK/MSD 2005
Moscow, Russia.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Replace credit card numbers with X ???

2005-01-25 Thread Afan Pasalic
this is my way.
   $cc_stars = '';
   $cc_no_lenght = strlen($cc_number);
   $cc_info_first4 = substr($cc_number, 0, 4);
   $cc_info_last4 = substr($cc_number, (strlen($cc_number) - 4), 4);
   for($i=0; $i<($cc_no_lenght-8); $i++) $cc_stars .= '*';
   $cc_number = $cc_info_first4 .$cc_stars. $cc_info_last4;
-afan
Joe Harman wrote:
Hello,
I need to replace all the numbers of a credit card except for the last
4 with an 'X' ... can't seem to locate the string function for this...
can someone point me in the right direction here to what php item i
should be using.
Thanks!
Joe
 

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


RE: [PHP] Replace credit card numbers with X ???

2005-01-25 Thread Jay Blanchard
[snip]
I need to replace all the numbers of a credit card except for the last
4 with an 'X' ... can't seem to locate the string function for this...
can someone point me in the right direction here to what php item i
should be using.
[/snip]

ROFLMMFAO! It's all been discussed before Joe! 

http://www.php.net/ereg_replace

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



[PHP] Replace credit card numbers with X ???

2005-01-25 Thread Joe Harman
Hello,

I need to replace all the numbers of a credit card except for the last
4 with an 'X' ... can't seem to locate the string function for this...
can someone point me in the right direction here to what php item i
should be using.

Thanks!
Joe

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



RE: [PHP] Replace or regex?

2004-09-30 Thread Dan Joseph
Hi,

> > I have a string: ##CODE## and I want to replace that with  > href="somewhere.php?id=CODE">CODE

I handle %code% tags in some templates I use...  here's the code I have..

function show ($template, $tag) {
$file = fopen ($template, "r") or
die($error_string());

while (!feof($file)) {
$line_in   = fgets($file, 1024);
$line_out .= $line_in;
}

if ($tag != 0) {
foreach ($tag as $name => $value) {
$line_out = str_replace ("%$name%",
$value, $line_out);
}
}

return $line_out;

fclose ($file);
}

Hope that helps..

-Dan Joseph

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



Re: [PHP] Replace or regex?

2004-09-30 Thread Brian
$var="##testcode##this is a ##code1## test of the ##code2## code
replacement system ##code3##";

$varParsed=strParse($var);
echo "$var";
echo $varParsed;

function strParse($origString)
  {
  while ( $offsetFALSE)
  {
  $tmpString=substr($origString, $lastEnd, $foundBeg-$lastEnd);
  $tmpCode=substr($origString, $foundBeg+2, $foundEnd-($foundBeg+2));
  $finalString=$finalString . $tmpString . "$tmpCode";
  $offset=$foundEnd+2;
  $lastEnd=$foundEnd+2;
  } else {
  echo "Parse Error";
  break;
  }
}
  return $finalString;
  }



On Thu, 30 Sep 2004 11:39:10 +0300, mario <[EMAIL PROTECTED]> wrote:
> Hi all
> 
> I have a string: ##CODE## and I want to replace that with  href="somewhere.php?id=CODE">CODE
> 
> can u help?
> 
> --
> 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] Replace or regex?

2004-09-30 Thread Graham Cossey
If you can change the ##text## to say /#text#/ it would be easier as you
could then do something like:

$id = substr($orig_text,strpos($orig_text, '/#')+2,strpos($orig_text,
'#/')-1);
$new_text = str_replace( '/#', 'href="somewhere.php?id='.$id.'">',
$orig_text);
$new_text = str_replace( '#/', '', $new_text);

see:
http://www.php.net/manual/en/ref.strings.php

HTH

Graham

-Original Message-
From: Gareth Williams [mailto:[EMAIL PROTECTED]
Sent: 30 September 2004 09:38
To: mario
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Replace or regex?



Well, if you can do it without a regex, then it's always best, because
the regex engine slows things down.

On 30 Sep 2004, at 10:39, mario wrote:

> Hi all
>
> I have a string: ##CODE## and I want to replace that with  href="somewhere.php?id=CODE">CODE
>
> can u help?
>
> --
> 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] Replace or regex?

2004-09-30 Thread Gareth Williams
Well, if you can do it without a regex, then it's always best, because 
the regex engine slows things down.

On 30 Sep 2004, at 10:39, mario wrote:
Hi all
I have a string: ##CODE## and I want to replace that with CODE
can u help?
--
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] Replace or regex?

2004-09-30 Thread mario
Hi all

I have a string: ##CODE## and I want to replace that with CODE

can u help?

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



Re: [PHP] replace accents

2004-09-14 Thread -{ Rene Brehmer }-
At 17:51 14-09-2004, Diana Castillo wrote:
Anyone know of any function to replace letters with accents with just the
regular letter, for instance replace á with a,
ç with c, ñ with n ?
How about this ??? This is the one I made for this purpose
function stripAccents($string) {
  $returnString = strtr($string,
  'àáâãäçèéêëìíîïñòóôõöšùúûüýÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕ֊ÙÚÛÜÝ', 
'acnosyACNOSY');
  $returnString = str_replace('æ','ae',str_replace('Æ','AE',$returnString));
  $returnString = str_replace('ø','o',str_replace('Ø','O',$returnString));
  $returnString = str_replace('å','a',str_replace('Å','å',$returnString));
  $returnString = str_replace('ß','ss',$returnString);
  $returnString = str_replace(''','',str_replace("'",'',$returnString));
  $returnString = str_replace('"','',str_replace('"','',$returnString));
  return $returnString;
}

obviously there's room for improvement, but it's from a QAD script (not 
production)

--
Rene Brehmer
aka Metalbunny
If your life was a dream, would you wake up from a nightmare, dripping of 
sweat, hoping it was over? Or would you wake up happy and pleased, ready to 
take on the day with a smile?

http://metalbunny.net/
References, tools, and other useful stuff...
Check out the new Metalbunny forums at http://forums.metalbunny.net/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] replace accents

2004-09-14 Thread Rick Fletcher
Diana Castillo wrote:
Anyone know of any function to replace letters with accents with just the 
regular letter, for instance replace á with a,
ç with c, ñ with n ?
found this on the strtr() manual page (http://php.net/strtr):
 'TH', 'þ' => 'th', 'Ð' => 'DH', 'ð' => 'dh',
 'ß' => 'ss', 'Œ' => 'OE', 'œ' => 'oe', 'Æ' => 'AE',
 'æ' => 'ae', 'µ' => 'u' )
);
}
?>
--rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] replace accents

2004-09-14 Thread Marek Kilimajer
Diana Castillo wrote:
Anyone know of any function to replace letters with accents with just the 
regular letter, for instance replace á with a,
ç with c, ñ with n ?


$string = str_replace(array('á', 'ç', 'ñ'), array('a', 'c', 'n'), $string);
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] replace accents

2004-09-14 Thread Greg Donald
On Tue, 14 Sep 2004 17:51:00 +0200, Diana Castillo <[EMAIL PROTECTED]> wrote:
> Anyone know of any function to replace letters with accents with just the
> regular letter, for instance replace á with a,
> ç with c, ñ with n ?

str_replace(), eregi_replace()


-- 
Greg Donald
http://destiney.com/

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



[PHP] replace accents

2004-09-14 Thread Diana Castillo
Anyone know of any function to replace letters with accents with just the 
regular letter, for instance replace á with a,
ç with c, ñ with n ?


-- 
Diana Castillo

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



Re: [PHP] Replace a button by an image

2004-07-30 Thread PHP Gen



> Jay Blanchard wrote:
> > Yes, anything is possible.
> 
> Can I be the next Queen of England?
> 
> -- 
> John C. Nichel

Anythings possible...and with all your choices you
want to be an old fart??

:-)



=
--
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)



__
Do you Yahoo!?
Y! Messenger - Communicate in real time. Download now. 
http://messenger.yahoo.com

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



Re: [PHP] Replace a button by an image

2004-07-30 Thread John Nichel
Jay Blanchard wrote:
Yes, anything is possible.
Can I be the next Queen of England?
--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Replace a button by an image

2004-07-30 Thread Jay Blanchard
[snip]
Is it possible to replace a button by an image with
PHP?
[/snip]

Yes, anything is possible. http://phpbutton.sourceforge.net/

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



[PHP] Replace a button by an image

2004-07-30 Thread Henri Marc
Hello,

Is it possible to replace a button by an image with
PHP?

Thanks!

Dave






Vous manquez d’espace pour stocker vos mails ? 
Yahoo! Mail vous offre GRATUITEMENT 100 Mo !
Créez votre Yahoo! Mail sur http://fr.benefits.yahoo.com/

Le nouveau Yahoo! Messenger est arrivé ! Découvrez toutes les nouveautés pour 
dialoguer instantanément avec vos amis. A télécharger gratuitement sur 
http://fr.messenger.yahoo.com

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



Re: [PHP] replace value of array by key of array in string variable with pre g_replace()

2004-07-26 Thread Jason Wong
On Monday 26 July 2004 10:09, Turbo wrote:

> I have array variable and string variable.
> I want to replace value of array by key of array  in string variable
> with preg_replace().
>
> Example :
> $message=array(
> 'name'=>'My Computer',
> 'version'=>'1.0'
> );
> $strValue="I am $name,build version $version\n";
>
> How's to replace?

I'm not sure what you're trying to do. Could you elaborate? In particular 
where does preg_replace() fit in?

It seems you want $strValue to be "I am My Computer,build version 1.0\n". If 
so:

1) you have completely misunderstood what preg_replace() is for
2) Use:
  $strValue="I am {$message['name']},build version {$message['version']}\n";
3) see manual > Types > Strings > 'Complex syntax'

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
A woman without a man is like a fish without a bicycle.
Therefore, a man without a woman is like a bicycle without a fish.
*/

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



[PHP] replace value of array by key of array in string variable with pre g_replace()

2004-07-25 Thread Turbo
Hi,
I have array variable and string variable.
I want to replace value of array by key of array  in string variable 
with preg_replace().

Example :
$message=array(
'name'=>'My Computer',
'version'=>'1.0'
);
$strValue="I am $name,build version $version\n";
How's to replace?
Yingyos
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] replace n first occurences of a char in a string

2004-07-23 Thread C.F. Scheidecker Antunes
Hello all,
If I have a string like this 123.456.789.01 , where dots are used to 
separate the thousands and the decimal part.

How can I first detect this situation? More than one dot. I guess I 
could use str_word_count() from the manual, right?

Then, once I have determined there are more than one dot, how can I 
remove all the dots but the right most one?

so 123.456.789.01 would become 123456789.01 with just the dot before the 
zero.

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


Re: [PHP] Replace space from form field using preg_replace

2004-03-17 Thread Red Wingate
str_replace(" ","+",$var);

-- red

Vernon wrote:

I want to be able to replace a space that comes from a form field (such as
in 123 My Street) with a + sign.
Can anyone help me with this?

Thanks

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


Re: [PHP] Replace space from form field using preg_replace

2004-03-17 Thread Adam Voigt
http://www.php.net/str-replace

On Wed, 2004-03-17 at 15:48, Vernon wrote:
> I want to be able to replace a space that comes from a form field (such as
> in 123 My Street) with a + sign.
> 
> Can anyone help me with this?
> 
> Thanks
-- 

Adam Voigt
[EMAIL PROTECTED]

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



[PHP] Replace space from form field using preg_replace

2004-03-17 Thread Vernon
I want to be able to replace a space that comes from a form field (such as
in 123 My Street) with a + sign.

Can anyone help me with this?

Thanks

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



[PHP] RE: [PHP-WIN] Re: [PHP] Replace of ' in a query

2004-02-17 Thread Svensson, B.A.T. (HKG)
Never trust the web...

Esacping is bad practis. Doing it, is to ask for trouble when you
try to port the code to another system that a) escapes in another
way, or b) does not escape at all, the transparent way to handle
quote are to quote them. This has been working for the last 40 to
50 years or so, and still works fine. Why not stay with a winner?

-Original Message-
From: Brent Baisley
To: carlos castillo
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: 2004-02-17 21:02
Subject: [PHP-WIN] Re: [PHP] Replace of ' in a query

Look at the addslashes command. You should always escape the values you 
are accepting from user input. If you read almost any article on web 
site security, it will mention something called SQL injection among 
other things. This is a way to compromise your data.
For instance, what if a user entered:
"1" OR "A"="A"

Now what if you used that user input to filter a query. You may end up 
with:
SELECT * FROM db WHERE field="1" OR "A"="A"

Which would return every record in the database.

On Feb 17, 2004, at 2:44 PM, carlos castillo wrote:

> Hi , i have the following problem, i have a form where a user can
input
> any text, on that text may be a char is ' char(39) when i try to 
> execute
> the sql query, i have an error for that ', i need to replace it for
the
> html tag, for example " is " or by chr(39) i dont know, and then
> execute the sql query.
>
> i really appreciate your help, thanks.
>
-- 
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577

-- 
PHP Windows 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] Replace of ' in a query

2004-02-17 Thread Brent Baisley
Look at the addslashes command. You should always escape the values you 
are accepting from user input. If you read almost any article on web 
site security, it will mention something called SQL injection among 
other things. This is a way to compromise your data.
For instance, what if a user entered:
"1" OR "A"="A"

Now what if you used that user input to filter a query. You may end up 
with:
SELECT * FROM db WHERE field="1" OR "A"="A"

Which would return every record in the database.

On Feb 17, 2004, at 2:44 PM, carlos castillo wrote:

Hi , i have the following problem, i have a form where a user can input
any text, on that text may be a char is ' char(39) when i try to 
execute
the sql query, i have an error for that ', i need to replace it for the
html tag, for example " is " or by chr(39) i dont know, and then
execute the sql query.

i really appreciate your help, thanks.

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Replace of ' in a query

2004-02-17 Thread Chris Shiflett
--- carlos castillo <[EMAIL PROTECTED]> wrote:
> Hi , i have the following problem, i have a form where a user can input
> any text, on that text may be a char is ' char(39) when i try to execute
> the sql query, i have an error for that ', i need to replace it for the
> html tag, for example " is " or by chr(39) i dont know, and then
> execute the sql query.

Yikes!

Never use user input directly in your SQL statements. This is very
dangerous.

There are functions to help you escape your data. For example, if you are
using MySQL, you can use this function:

http://www.php.net/mysql_escape_string

However, you should also validate your data before doing anything else.
Make sure it is exactly what type of data you are expecting, then escape
the string just prior to constructing your SQL statement.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly
 Coming mid-2004
HTTP Developer's Handbook - Sams
 http://httphandbook.org/
PHP Community Site
 http://phpcommunity.org/

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



[PHP] Replace of ' in a query

2004-02-17 Thread carlos castillo

Hi , i have the following problem, i have a form where a user can input
any text, on that text may be a char is ' char(39) when i try to execute
the sql query, i have an error for that ', i need to replace it for the
html tag, for example " is " or by chr(39) i dont know, and then
execute the sql query.

i really appreciate your help, thanks.

Carlos A. Castillo.
Ingeniero de desarrollo
[EMAIL PROTECTED]


Su Aliado Efectivo en Internet
www.imagine.com.co
(57 1)2182064 - (57 1)6163218
Bogotá - Colombia 

- Soluciones web para Internet e Intranet
- Soluciones para redes
- Licenciamiento de Software
- Asesoría y Soporte Técnico


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



Re: [PHP] replace ' with "

2004-02-11 Thread John Nichel
Diana Castillo wrote:

How do I replace all single quotes with double quotes in a string for
echoing it with the double quotes?
By looking here...

http://us4.php.net/str_replace

--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] replace ' with "

2004-02-11 Thread Angelo Zanetti

str_replace(''',"'", $StringToReplace);

should work

-Original Message-
From: Diana Castillo [mailto:[EMAIL PROTECTED]
Sent: Wednesday, February 11, 2004 4:33 PM
To: [EMAIL PROTECTED]
Subject: [PHP] replace ' with "


How do I replace all single quotes with double quotes in a string for
echoing it with the double quotes?

--
Diana Castillo
Global Reservas, S.L.
C/Granvia 22 dcdo 4-dcha
28013 Madrid-Spain
Tel : 00-34-913604039 ext 214
Fax : 00-34-915228673
email: [EMAIL PROTECTED]
Web : http://www.hotelkey.com
  http://www.destinia.com

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


Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender 
of this e-mail be liable to any party for any direct, indirect, 
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



Re: [PHP] replace ' with "

2004-02-11 Thread Stuart
Diana Castillo wrote:
How do I replace all single quotes with double quotes in a string for
echoing it with the double quotes?
$text = str_replace("'", '"', $text);

http://php.net/str_replace and please at least RTFM before posting here 
in future.

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


[PHP] replace ' with "

2004-02-11 Thread Diana Castillo
How do I replace all single quotes with double quotes in a string for
echoing it with the double quotes?

--
Diana Castillo
Global Reservas, S.L.
C/Granvia 22 dcdo 4-dcha
28013 Madrid-Spain
Tel : 00-34-913604039 ext 214
Fax : 00-34-915228673
email: [EMAIL PROTECTED]
Web : http://www.hotelkey.com
  http://www.destinia.com

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



Re: [PHP] replace %rand[x]-[y]% macro in string with random string

2003-12-04 Thread daniel hahler
on Tue, 2 Dec 2003 23:46:33 +0100 I already wrote, regarding replacing
macro %rand[x]-[y] with random of random length ([x]-[y]).

Before, I had my own (slow!) procedure to find next occurence of the
macro and generated a new string, which was returned.

This took about 15 seconds for 10.000 addresses, where the macro could
appear. As this was too slow, I rewrote it to use preg_replace (what a
cool thing, to use a function as replacement) and this takes it down
to about 2,5 seconds!!

Very great - just want to lez you know that.. ;)

So this is it:

 // replaces %rand[x]-[y]% with random text with length between [x] and [y]
 function parserandstr($toparse){
  function genrandstr($minlen, $maxlen){
   echo $minlen, $maxlen, '';
   $ch = array(
'punct' => array('.', '.', '.', '..', '!', '!!', '?!'),
'sep' => array(', ', ' - '),
'vocal' => array('a', 'e', 'i', 'o', 'u'),
'cons_low' => array('x', 'y', 'z'),
'cons_norm' => array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 
'q', 'r', 's', 't', 'v', 'w')
   );
   $ch['newlineafter'] = array_merge(' ', $ch['punct'], $ch['sep']);

   $rlen = rand($minlen, $maxlen);

   // generate random string
   $randstr = ''; $inword = 0; $insentence = 0; $lastchar = ''; $lastwasvocal = false; 
$lastnewline = 0;
   $rbreak = rand(0, 100);
   for ($j = 0; $j < $rlen; $j++){
if ($inword > 3 && rand(0, 5) == 1) {  // punctuation chars
 if (rand(0,5) > 0) $char = ' ';
 else {
  $char = $ch['punct'][rand(0, count($ch['punct'])-1)] . ' ';
  $j += strlen($char)-1;
  $insentence = 0;
 }
 $inword = 0;
}
else {
 if (!$lastwasvocal && rand(0, 10) > 6) {  // vocals
  $char = $ch['vocal'][rand(0, count($ch['vocal'])-1)];
  $lastwasvocal = true;
 } else {
  do {
   if (rand(0, 30) > 0)  // normal priority consonants
$char = $ch['cons_norm'][rand(0, count($ch['cons_norm'])-1)];
   else $char = $ch['cons_low'][rand(0, count($ch['cons_low'])-1)];
  } while ($char == $lastchar);
  $lastwasvocal = false;
 }
 $inword++;
 $insentence++;
}

if ($insentence == 1 || ($inword == 1 && rand(0, 30) < 10)) $randstr .= 
strtoupper($char);
else $randstr .= $char;
$lastchar = $char;
if ($lastnewline > $rbreak && rand(0, 30) > 10 && in_array($char, 
$ch['newlineafter'])){
 $randstr .= "\n";
 $lastnewline = 0;
 $rbreak = rand(0, 100);
} else $lastnewline++;
   }
   return $randstr;
  }

  $pattern = array('/%rand(\d+)-(\d+)%/e', '/%rand%/e');
  $replace = array('genrandstr($1, $2)', 'genrandstr(5, 40)');
  return preg_replace($pattern, $replace, $toparse);
 }


-- 
shinE!
http://www.thequod.de ICQ#152282665
PGP 8.0 key: http://thequod.de/danielhahler.asc

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



Re: [PHP] replace %rand[x]-[y]% macro in string with random string

2003-12-02 Thread daniel hahler
on 02 Dec 2003 18:56:28 -0500 Robert Cummings wrote:

RC> I missed the original post, and I'm too lazy to go looking, but the
RC> following code runs in approx. 2.75 seconds on my Athlon 2400 running
RC> linux:

it is 4.3 seconds on xp 1600+..

RC> $chars = '0123456789'
RC> .'abcdefghijklmnopqrstuvwxyz'
RC> .'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

RC> $charArray = array();
 
RC> for( $i = 0; $i < 100; $i++ )
RC> {
RC> $charArray[] = $chars[rand( 0, 61 )];
RC> }

RC> It's runs much faster than using a .= style of string creation.

..and replacing "$charArray[] =" with "$s .=" crawls this down to 3.5
seconds - so this is faster here..

winxp, php 4.3.4, Apache 1.xx


-- 
shinE!
http://www.thequod.de ICQ#152282665
PGP 8.0 key: http://thequod.de/danielhahler.asc

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



Re: [PHP] replace %rand[x]-[y]% macro in string with random string

2003-12-02 Thread daniel hahler
on Tue, 2 Dec 2003 23:33:47 + Richard Davey wrote:

RD> Just so we're clear on this - you're creating a string (an email
RD> address) of a million characters? I don't know my mail RFC's that well, but
RD> I'm sure this is well beyond what it considers "standard".

We're not clear.. ;)
the function I've posted is designed for templates, that handle the
output my script generates.. it's useful to have non-email text
portions in between or a short random string for the mailto-links
description..

RD> Does the string HAVE to make sense?

I found it better to follow some rules..
At first that were spaces in between and it got bigger.. if I'd write
a spambot I would check if the page I'm lurking on is a oneliner or
does only contain non-email words with > 20 characters, and so on..


-- 
shinE!
http://www.thequod.de ICQ#152282665
PGP 8.0 key: http://thequod.de/danielhahler.asc

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



Re: [PHP] replace %rand[x]-[y]% macro in string with random string

2003-12-02 Thread Robert Cummings
On Tue, 2003-12-02 at 18:33, Richard Davey wrote:
> Hello Daniel,
> 
> Tuesday, December 2, 2003, 10:46:33 PM, you wrote:
> 
> dh> For generation of a random string with length 1.000.000 it takes about
> dh> 13 seconds on my xp 1600+.. that's quite a lot, imho, so suggestions
> dh> are very welcome..
> 

I missed the original post, and I'm too lazy to go looking, but the
following code runs in approx. 2.75 seconds on my Athlon 2400 running
linux:

$chars = '0123456789'
.'abcdefghijklmnopqrstuvwxyz'
.'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

$charArray = array();
 
for( $i = 0; $i < 100; $i++ )
{
$charArray[] = $chars[rand( 0, 61 )];
}

It's runs much faster than using a .= style of string creation.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] replace %rand[x]-[y]% macro in string with random string

2003-12-02 Thread Richard Davey
Hello Daniel,

Tuesday, December 2, 2003, 10:46:33 PM, you wrote:

dh> For generation of a random string with length 1.000.000 it takes about
dh> 13 seconds on my xp 1600+.. that's quite a lot, imho, so suggestions
dh> are very welcome..

Just so we're clear on this - you're creating a string (an email
address) of a million characters? I don't know my mail RFC's that well, but
I'm sure this is well beyond what it considers "standard".

Does the string HAVE to make sense? I mean does a spambot really
care less, or can even detect, what the email address contains? Surely
just creating a truly random string would suffice (and indeed remove
the need for the rather elaborate function you posted). I fully accept
I might be missing the whole point here :)

-- 
Best regards,
 Richardmailto:[EMAIL PROTECTED]

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



[PHP] replace %rand[x]-[y]% macro in string with random string

2003-12-02 Thread daniel hahler
Hello PHP-list,

I'm building a script, that provides a honeypot of invalid email
addresses for spambots.. for this I want to provide a macro for the
templates that looks like %rand[x]-[y]%, where [x] and [y] are
integers, that specify the length of the random script.
My first thoughts were about the best parsing of the %rand..%-part,
but now I came to a point, where I could also need suggestions on the
random string generation..
It considers very basic word generations and the only meaningful word
I discovered was 'Java'.. *g

For generation of a random string with length 1.000.000 it takes about
13 seconds on my xp 1600+.. that's quite a lot, imho, so suggestions
are very welcome..

the script goes here, ready to copy'n'paste:

--
list($low, $high) = explode(" ", microtime());
$this->timerstart = $high + $low;

function parserandstr($toparse){
 $debug = 0;

 $new = '';
 $ch = array(
'punct' => array('.', '.', '.', '..', '!', '!!', '?!'),
'sep' => array(', ', ' - '),
'vocal' => array('a', 'e', 'i', 'o', 'u'),
'cons_low' => array('x', 'y', 'z'),
'cons_norm' => array('b', 'c', 'd', 'f', 'g', 'h', 'j', 'k',
 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v', 'w')
 );
 while ( ($pos = strpos($toparse, '%rand')) !== FALSE){
  if ($debug) echo '$pos: ' . $pos;
  $new .= substr($toparse, 0, $pos);
  if ($debug) echo '$new: "' . $new . '"';

  $toparse = substr($toparse, $pos + 5);
  if ($debug) echo '$toparse: "' . $toparse . '"';
  
  $posclose = strpos($toparse, '%', 1);
  if ($debug) echo '$posclose: "' . $posclose . '"';
  if ($posclose){
   $rlength = substr($toparse, 0, $posclose);
   if ($debug) echo '$rlength: "' . $rlength . '"';
   
   $possep = strpos($rlength, '-');
   $minrlen = substr($rlength, 0, $possep);
   $maxrlen = substr($rlength, $possep + 1);
   if ($debug) echo '$minrlen: "' . $minrlen . '"';
   if ($debug) echo '$maxrlen: "' . $maxrlen . '"';
   
   $rlen = rand($minrlen, $maxrlen);
   
   // generate random string
   $randstr = ''; $inword = 0; $insentence = 0; $lastchar = '';
   for($j = 0; $j < $rlen; $j++){
  if ($inword > 3 && rand(0, 5) == 1) {  // punctuation chars
   if (rand(0,5) > 0) $char = ' ';
   else {
$char = $ch['punct'][rand(0, count($ch['punct'])-1)] . ' ';
$j += strlen($char)-1;
$insentence = 0;
   }
   $inword = 0;
  }
  else {
   if (!$lastwasvocal && rand(0, 10) > 6) {  // vocals
$char = $ch['vocal'][rand(0, count($ch['vocal'])-1)];
$lastwasvocal = true;
   } else {
  do {
   if (rand(0, 30) > 0)  // normal priority consonants
$char = $ch['cons_norm'][rand(0, count($ch['cons_norm'])-1)];
   else $char = $ch['cons_low'][rand(0, count($ch['cons_low'])-1)];
  } while ($char == $lastchar);
  $lastwasvocal = false;
   }
   $inword++;
   $insentence++;
}

if ($insentence == 1 || ($inword == 1 && rand(0, 30) < 10))
 $randstr .= strtoupper($char);
else $randstr .= $char;
$lastchar = $char;
   }
   
   $new .= $randstr;
   if ($debug) echo '$new: ' . $new;

   $toparse = substr($toparse, $posclose + 1);
   if ($debug) echo '$toparse: "' . $toparse . '"';
  } else $new .= '%rand';
 }
 return $new . $toparse;
}
 
function pre_dump($var, $desc=''){
 echo '::'.$desc.'::'; var_dump($var); echo '';
}

#$s = parserandstr('random string comes here: '
. '%rand10-1000%. this is a fake %rand and should not be killed..');
$s = parserandstr('%rand20-20%');
echo '' . $s;
echo '' . strlen($s);

list($low, $high) = explode(" ", microtime());
$t= $high + $low;
printf("loaded in: %.4fs", $t - $this->timerstart);



-- 
shinE!
http://www.thequod.de ICQ#152282665
PGP 8.0 key: http://thequod.de/danielhahler.asc

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



Re: [PHP] replace a chunk peace of string

2003-12-01 Thread Curt Zirzow
* Thus wrote ada ([EMAIL PROTECTED]):
> > What do you mean trim() doesn't work?
> 
> trim is a basic function that remove spaces on the left and the right at the
> string :
> " abc"->"abc"

trim() removes more than spaces, please read:
  http://php.net/trim


What I meant in my original post was how are you using trim() that
doesn't make it work?  trim() *will* fix your problem.


Curt
-- 
If eval() is the answer, you're almost certainly asking the
wrong question. -- Rasmus Lerdorf, BDFL of PHP

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



Re: [PHP] replace a chunk peace of string

2003-12-01 Thread ada
> What do you mean trim() doesn't work?

trim is a basic function that remove spaces on the left and the right at the
string :
" abc"->"abc"

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



  1   2   >