PHP - Moved: Why Does One Replace Work And The Other Not?
This topic has been moved to PHP Regex.
http://www.phpfreaks.com/forums/index.php?topic=314913.0 Similar TutorialsI am trying to do the seemingly simple thing - replace all single quotes in text str_replace ("'", "´", $text); It does not replace anything. I trying escaping single quote, using other similar functions - nope. Also tried to google What I an doing wrong? Any help would ne much appreciated. This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=328966.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=351288.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=321641.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=319445.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=306153.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=343073.0 The situation is that I have a large string with some identifiers to say "replace me" with something else. My goal is to replace the values, but if one replacement includes one of the other keys, I don't want to replace it.
For example:
<?php $str = 'some blob ~abc~ followed by ~def~'; $arr_orig = array( '~abc~', '~def~' ); $arr_new = array( 'value~def~', 'blah' ); echo str_replace( $arr_orig, $arr_new, $str ); ?>This will echo: some blob valueblah followed by blah But that's not what I'm trying to accomplish. Basically, I want ~abc~ to be replaced with the literal: value~def~ and for the ~def~ that happens to be part of that string to NOT be replaced. I hope what I'm asking is clear. Basically, preg_replace/str_replace with arrays seems no different than just doing a FOR loop and replacing ~abc~ and then ~def~. But that's not what I need. I'm hoping that if ~abc~ is replaced with text that happens to be another identifier -- ~def~, ~xyz~, whatever -- that this already replaced text is not again replaced. Is there a built-in function to do something like this? If not, should I just parse the whole string and count characters or something? Seems like a pain (and slow!) This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=327247.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=342142.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=348530.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=356485.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=321864.0 This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=331514.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=356031.0 Hi i wrote a find and replace code but my code replace last value of array and skip the first, second.... values in the array. Please give me an idea because i stack with this code. Regards $KeyWord = explode("\n", $RowGetWords['KEYWORDS']); $Replace = explode("\n", $RowGetWords['ReplaceTo']); for($i=0; $i<count($KeyWord); $i++){ $pattern = $KeyWord[$i]; $replace = "<a href=\"" .$URL. "\" target=\"_blank\" >" .$Replace[$i]. "</a>"; $html = str_replace($pattern, $replace, $Row['MessageBody']); } This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=330364.0 I had to move hosters recently and I have a couple of scripts run using CRON to backup my MySql database and manage the number of backups that I keep. I can ask the hosters to deprecate the version of PHO backwards but I don't want to lose the opportunity of features that may be available in the new version. The main script essentially performs a MySqlDump to a specified directory and then emails me to tell me that it completed successfully. The second script just deletes any files in the backup folder more than x days old. I know mysqldump is a valid call so I should need to use anything other than that but I'm lost when it comes to seeing what is wrong with my scripts. backup.php
<?
/* CONFIGURE THE FOLLOWING SEVEN VARIABLES TO MATCH YOUR SETUP */
//$dbuser = $db_user, $conection ; // Database username
$command = "mysqldump -u $db_user --password=$db_password $db_name | gzip > $filename"; copy ($filename, $backdir.$newfile);
unlink($filename); //delete the backup file from the server
and delold.php
<?php
//echo "script is running";
if (is_dir("$path") )
}
This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=349470.0 This topic has been moved to Other Programming Languages. http://www.phpfreaks.com/forums/index.php?topic=354391.0 |