Search Results

Search found 2 results on 1 pages for 'woz'.

Page 1/1 | 1 

  • Write to the second line of a PHP file

    - by Woz
    I have a php file that I want to add an include path to on the second line. I need to open the file and inset a line of code on line 2. I have tried a few techniques none of which are working but I think it has something to do with the text I am trying to write and possibly not escaping character correctly as I am not too familiar with file writing. So here is the file I want to write to: $file = $_SERVER['DOCUMENT_ROOT'].'/'.$domaindir.'/test.php'; Here is the piece of text I want to insert into the file: $dbfile = "include('".$_SERVER['DOCUMENT_ROOT']."/".$domaindir."/web_".$dbname.".inc.php');"; Then what I was doing was a string replace but all it did was bump the "session_start();" bit to a newline! Can anyone point me in the direction of a tutorial that might tell me how to insert this into the second line of my php file or indeed if anyone has any ideas? I can say for sure that the path to the PHP file is fully tested so i know its not that the file is not being open or written to. Any ideas would be much appreciated. Thanks in advance.

    Read the article

  • .find replacing content inside html tags

    - by Woz
    I want to sanitize html tags from my wysiwyg. I want to replace certain tags with another. This almost works only the replaceWith() is also removing the content from within the tags. I dont want to do this. I just want to replace the tags. Here is what I have so far. Text for Testing: This<div>is</div><div>a test</div><div>to clean&nbsp;</div><div>some tags</div><div><br></div> Expected Result: This<p>is</p><p>a test</p><p>to clean</p><p>some tags</p><p><br></p> Actual Result: This<p></p><p></p><p></p><p></p><p></p> This is the code I am using to find and replace var thebad = ["h1","h2","h3","h4","h5","h6","div"]; var thegood = ["","","","","","","<p>"]; for(var i = 0; i < thebad.length; i++){ $('.content').contents().find('body').find(thebad[i]).replaceWith(thegood[i]); } I need to figure out how to keep the text inside the html tags when i replace them. Thanks in advance

    Read the article

1