问题
My folder contains about 500 files (html). Each files contain this script
<script type="text/javascript"><!--
google_ad_client = "??????";
/* unit1 */
google_ad_slot = "??????";
google_ad_width = 120;
google_ad_height = 90;
//-->
</script>
I want to replace above code with this
<script type="text/javascript" src="/wp-content/themes/twentyfourteen/open.js"></script>
I used this code >>is good
http://pastebin.com/wuWupgBg
This find and replace in php only but no find and replace in html. Can anyone make it find and replace in html files?
回答1:
Not really what we do here, but I would think you would just change line 17:
if( is_file( $path ) && substr($path, -3)=='php' && substr($path, -17) != 'ChangePHPText.php'){
to
if( is_file( $path ) && substr($path, -4)=='html' && substr($path, -17) != 'ChangePHPText.php'){
Though honestly, if you're doing that much text change, you may find a text editor that does string replacement in files to be much faster.
回答2:
replace this code:
if( is_file( $path ) && substr($path, -3)=='php' && substr($path, -17) != 'ChangePHPText.php'){
with:
if( is_file( $path ) && substr($path, -4)=='html' && substr($path, -17) != 'ChangePHPText.php'){
来源:https://stackoverflow.com/questions/24592503/find-and-replace-in-multiple-files-using-php