LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-14-2015, 03:51 AM   #1
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Rep: Reputation: 73
php: character replacement


Hello, I'm trying to figure out how to replace in php

Code:
'
and
Code:
`
with
Code:
_
?

Does anybody know?
 
Old 07-14-2015, 05:55 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
there is a function named str_replace which should do the trick.
 
Old 07-15-2015, 04:47 AM   #3
robertjinx
Member
 
Registered: Oct 2007
Location: Prague, CZ
Distribution: RedHat / CentOS / Ubuntu / SUSE / Debian
Posts: 749

Original Poster
Rep: Reputation: 73
I know that, but how?

Quote:
$str = str_replace("'", "_", $str);
Something like this? How about both at the same time?
 
Old 07-15-2015, 07:09 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by robertjinx View Post
I know that, but how?
The doc is here http://php.net/manual/en/function.str-replace.php.
I'd say your example should work, why don't you try?
If I understand the doc right, the first parameter can be an array containing each of the characters you want to replace.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Trigger email from script if the Character replacement is successfull nanduedi Linux - General 4 05-08-2015 05:03 AM
[SOLVED] Pattern matching and replacement in a character stream. stf92 Programming 21 01-11-2015 06:28 PM
[SOLVED] sed character replacement XXLRay Linux - General 6 04-27-2011 07:35 AM
multiple character replacement by shell script mauran Programming 14 07-13-2007 02:46 AM
Character replacement SeT Linux - General 1 11-18-2004 12:21 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:28 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration