21 Topics

Member Avatar for
Member Avatar for b.wickham

I've been having trouble with an UPDATE statement in the code below. The problem is that each time I submit the form to update an existing record in the products table, the records won't update. When I submit the form there is no error message and it redirects to the …

Member Avatar for b.wickham
0
1K
Member Avatar for tpickett

I am developing a script that takes an article, searches the article for a "keyword" and then randomly replaces that keyword with an anchor link. I have the script working as it should, however I need to be able to have an array of "replacements" for the function to loop …

Member Avatar for tpickett
0
206
Member Avatar for diafol

Hi all. AM having a little issue with regex. Not one of my strongest skills! I'm trying to produce a simple translation system that doesn't require arrays, gettext etc. It basically has this structure: $content=<<<CONTENT <p>{{Dyma destun||Here's some text}}</p> ... CONTENT; So the page content is held in a var …

Member Avatar for diafol
0
309
Member Avatar for magicmarkuk

Hi I am having trouble understanding how the pre_replace function works. I am using a script which has the following line: $ret = preg_replace("#(@|telefone|e-mail|.com|skype|.com.br|fone|www.|hotmail|yahoo|ig|aol|uol|gmail|bol|msn|MSN)#i", "\\1scriptolutionreplacement", $ret); What is happening is that any word with for example the letters ig or uol in it is getting caught. Is there a way …

Member Avatar for magicmarkuk
0
148
Member Avatar for klemme

Hi all, I want to replace these charachters: Æ,Ø,Å,æ,ø,å, with, AE,OE,AA,ae,oe,aa I thoght I could use preg_replae this way to accomplish that, but if i write this word in the form: "Bælter" - All that is left to be inserted into the DB is "B" - So I am removing …

Member Avatar for klemme
0
177
Member Avatar for IanArcher

Hi, i am new to PHP but i have some common knowledge to recognizing commands and such. in my page i have code like this [CODE]<div class="page_column page_column_first" id="page_column_1" style="width: 499px;"><div class="page_block_container" id="page_block_759"><div class="disignBoxFirst"> <div class="boxFirstHeader"><div class="dbTitle">Up and Coming</div></div> <div class="boxContent"><div class="dbContentHtml"><p>This is a placeholder for up and coming news …

Member Avatar for pritaeas
0
168
Member Avatar for utroda

Hello, I'm trying to replace {include %filename.php%} with that file from the server. I can get this to work file if the file is plan html text using the function below. [CODE] $str = "This would be a paragraph of text. {include %news.php%}"; preg_replace_callback("/\{include %(.*?)\%}/", function($m) { return file_get_contents(CORE . …

Member Avatar for utroda
0
332
Member Avatar for utroda

Hello, I'm looking for some help on the following line of code, it keeps throwing an error. [I]Parse error: syntax error, unexpected T_FUNCTION Line 168.[/I] The code below is line 168. [CODE]$content = preg_replace_callback("/\{include '(.*?)'}/", function($m) { return file_get_contents(CORE . 'includes/' .$m[1]);}, $str);[/CODE] Any ideas?

Member Avatar for pritaeas
0
207
Member Avatar for Dani

Hi, How can I use preg_replace to determine if a string contains a word beginning with a pattern, and if it does, remove it? Basically I want to capture query strings from a search, but throw away search modifiers. For example, the search query string: site:daniweb.com query would just become …

Member Avatar for diafol
0
2K
Member Avatar for Hummdis

I've tried this a number of different ways and I've even downloaded the Regular Expression reference sheet from addedbytes.com, but I just can't figure out how to move this eregi_replace() statement into a preg_replace() statement. I've read and understood the delimiter requirements for preg_replace(), but I think the problem is …

Member Avatar for Hummdis
0
236
Member Avatar for NuGG

I have the following code witch is used to display HTML from an XML file. The XML file itself comes from a form POST where a "\" is added in after various HTML tags. Is there anyway I can modify the script below to hide/remove the "\" when the XML …

Member Avatar for ko ko
0
1K
Member Avatar for diafol

Hi all, preg-Replace has stumped me again. I'm just too thick to get it. This is my problem: I have two files. File 'newvalues.php' with an array like so: [CODE].... $lang['this_key'] => 'blah blah blah'; $lang['another_key'] => 'rhubarb rhubarb'; $lang['something_else_key'] => 'twitter twitter'; ....[/CODE] And another file: 'template.php' like so: …

Member Avatar for diafol
0
156
Member Avatar for russellharrower

So I got most of the code working, but what I am trying to do, is say someone post the following This is a great youtube video [url]http://www.youtube.com/watch?v=pkrM7x0_fcI&feature=channel[/url] what do you think. I want it to turn the youtube link to [url]http://www.youtube.com/v/pkrM7x0_fcI[/url] but keep the text that they typed so …

Member Avatar for vinnyBenson
0
605
Member Avatar for lobstar

Hi, I am using cURL to grab the contents of a webpage which contains a table. I am trying to make an array out of the table contents, with the column headings as the array keys. Unfortunately the first row of the table, before the headers, has pagination which is …

Member Avatar for lobstar
0
462
Member Avatar for matt_platts

Im trying to use a regular expression backreference to reference a hash key. Here's an example of the non working code so you can see what I'm trying to achieve (I hope!): [CODE] $str="String of text containing item1 and item2"; $x['item1']="Item 1"; $x['item2']="Item 2"; $str=preg_replace("/item1/","$x[\${1}1]",$str); print $str; [/CODE] I want …

Member Avatar for matt_platts
0
134
Member Avatar for farhan386

I have a string contains sequences of 0 and 1. I need to replace all zero sequences whose length less than 5, into number 1 with same length. The zero sequences with length 5 or more should be left as is. For example source : 11000001100010011000001 result : 11000001111111111000001 [CODE] …

Member Avatar for farhan386
0
171
Member Avatar for phphit

Ok. I have ZERO PHP Knowledge, still good in editing php and all that stuff. Only know copy paste and have no knowledge what that means. Still would try to explain my problem. I use variable to fetch data from mysql. Ex. my url is [url]http://www.example.com/venue.php?vcity=New[/url] York. Now, I want …

Member Avatar for phphit
0
285
Member Avatar for SerjSagan

I am planning to use preg_replace to remove some unwanted stuff from dynamic string $mystring: <ul><li><a href="http://www.url.com/wiki/How_to_fix_erection_problems_after_prostate_surgery&amp;diff=335&amp;oldid=prev">How to fix erection problems after prostate surgery</a></li> <li><a href="http://www.url.com/wiki/Wikipenis:Community_Portal&amp;diff=334&amp;oldid=prev">Wikipenis:Community Portal</a></li> </ul> This string is generated from an RSS reader. (The url has obviously been replaced to make sure no one thinks this is …

Member Avatar for SerjSagan
0
151
Member Avatar for sallecpt

hey all. I am trying to do validation via PHP for submitted forms. Below is my own code, please comment if its the correct method or not. However, I tried so many ways to have the /n or /r added, but I cant get to it. Its just to make …

Member Avatar for sallecpt
0
194
Member Avatar for Frankey

Hi there, I am building a blog at the moment i have a amazing script that search a post for the images in it. So i can just setup a post template, call the images that are in the post and go. In this way i put the images unedited …

Member Avatar for Frankey
0
192
Member Avatar for diafol

Hi folks, I'm looking for a function, similar to str_replace that replaces just the first occurance of a specified string. I have found such a function: [url]http://www.help2go.com/Tutorials/Programming/PHP_:_How_to_replace_only_the_first_occurrence_in_a_string_with_str_replace.html[/url] However, this does not take into consideration of 'search from an initial position'. My interest is with regard to replacing strings within a …

Member Avatar for diafol
0
169

The End.