What is the best way of replacing a set of short tags in a PHP string, example:
$return = "Hello %name%, thank you for your interest in the %product_name%. %representative_name% will contact you shortly!";
Where I would define that %name% is a certain string, from an array or an object such as:
$object->name;
$object->product_name;
...
I need to open a file , replace some content( 12345 with 77348) and save it. As far I have
$cookie_file_path=$path."/cookies/shipping-cookie".$unique;
$handle = fopen($cookie_file_path, "r+");
$cookie_file_path = str_replace("12345", "77348", $cookie_file_path);
fclose($handle);
However it doesn't seem to work .... I would app...
Hey guys,
I am retrieving a variable that contains a £ sign from another page.
I want to remove this and I have tried using str_replace
but I am left with the following:
�100.
$amount = str_replace('£', '', $amount);
Any ideas?
...
Could you tell how to replace string by preg-replace (need regular expression):
/user/{parent_id}/{action}/step/1
At the equivalent values of an array:
array('parent_id'=>32, 'action'=>'some');
To make:
/user/32/some/step/1
Addition
This is a typical problem, so I probably will not know what the names of variables come
...
Hello,
I would like to make a whole word replace using php
Example :
If I have
$text = "Hello hellol hello, Helloz";
and I use
$newtext = str_replace("Hello",'NEW',$text);
The new text should look like
NEW hello1 hello, Helloz
PHP returns
NEW hello1 hello, NEWz
Thanks.
...
Hi
I have the following code
<a href="snippet:add?code=<?php echo rawurlencode($snippet->snippet_content); ?>Save snippet</a>
where
'$snippet = <a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=&lt;?php the_permalink(); ?>" title="Submit this post to Digg">Digg this!</a...
Some background information: We have an ancient web-based document database system where I work, almost entirely consisting of MS Office documents with the "normal" extensions (.doc, .xls, .ppt). They are all named based on some sort of arbitrary ID number (i.e. 1245.doc). We're switching to SharePoint and I need to rename all of these f...
I have a massive string im trying to parse as series of tokens in string form, and i found a problem: because many of the strings are alike, sometimes doing string.replace()will cause previously replaced characters to be replaced again.
say i have the string being replaced is 'goto' and it gets replaced by '41' (hex) and gets converted ...
i have a lil problem here..i'm using str_replace to replace the most common words..and for some reason its replacing every letter except caps.
for example..if i had the code below
$str ="Fat string of Text.";
$commonwords = array('fat','of','random');
$cleantext = str_replace($commonwords,'',$str);
echo $cleantext;
it would echo...
Hello,
I wondered if it was possible to rewrite a URL so designed for the rewrite wrote in htaccess
e.g.
I have the URL: http://example.com/page.php?page=5&action=something
But I want to change the URL to: example.co m/page/5/something
This is just for the href, the htaccess bit is solved.
...
Hi,
I'm using str_replace and it's not working correctly.
I have a text area, which input is sent with a form. When the data is received by the server, I want to change the new lines to ",".
$teams = $_GET["teams"];
$teams = str_replace("\n",",",$teams);
echo $teams;
Strangely, I receive the following result
Chelsea
,real
,Barcelon...
I'm working on a WordPress plugin that exports posts and associated data into a tab-seperated text format. It's almost finished, but I'm struggling to find the best method to re-process HTML into single strings.
I'm using a combination of preg_replace and htmlentities, but it's getting a little messy.
I'm sure there must be a preferred...
hi there!
i got this crappy website i need to parse and the html-element i need to get the contents of contains "€" symbols. the actual html of this page looks like this:
<td>Mais-Lauch-Rösti <font color=#000000 size=1>(1,2,9,11)</font> mit Paprikasauce <font color=#000000 size=1>(3,9)</font><nobr><b> 2,10 €</b></nobr><br/>.....
My client is a small newspaper and provides stories with typographer's quotes instead of "straight" quotes. The stories are assembled into HTML by PHP. On my Apache server, they display fine, but on Yahoo, where my client's site is located, they are all replaced by question marks.
To fix this problem, I wrote the following function in P...
$line-out = str_replace('\r', '', str_replace('\n', '', $line-in));
The above works for me but, I saw a [\n\r] example somewhere and I cannot seem to find it.
I just want to get rid any blank lines. The above is in a foreach loop.
Thanks for teaching.
...
// Build email link
confirmLink = Master.siteDomain + "/newsLetter.aspx?action=confirm&e=" + emailAddress + "&code=" + verCode;
using (SqlCommand cmd = new SqlCommand("SELECT newRegEmailBody, newRegEmailSubj FROM tblSiteSettings WHERE (isActive = 1)", Master.cn))
{
SqlDataReader rdr = cmd.Exec...
Hello,
I want to change words from list (in file or database) into links in HTML website. I used str_replace, but i have problem with replacing words, that are already in links auchor.
eg. I have html like this:
Lorem ipsum donor et simet <a>lorem ipsum</a> eta raoa talkesa z uta.
An i want to replace all "ipsum" into links, but skip...
A php variable contains the following string:
<p>text</p>
<p>text2</p>
<ul>
<li>item1</li>
<li>item2</li>
</ul>
I want to remove all the new line characters in this string so the string will look like this:
<p>text</p><p>text2><ul><li>item1</li><li>item2</li></ul>
I've tried the following without success:
str_replace('\n', '', $st...
Hi there,
I'm trying to get a users ID from a string such as:
http://www.abcxyz.com/123456789/
To appear as 123456789 essentially stripping the info up to the first / and also removing the end /. I did have a look around on the net but there seems to be so many solutions but nothing answering both start and end.
Thanks :)
Update 1
...