Badchip Posted May 16, 2017 Share Posted May 16, 2017 (edited) How to open my homepage "index.html" (via php) and remove the lines: <a href="http://player.mysite.com/player.php?vid=site.com/file.m3u8"> ... (The result would be <a href="http://site.com/file.m3u8"> Thank you in advance. Edited May 16, 2017 by Badchip Link to comment Share on other sites More sharing options...
justsomeguy Posted May 16, 2017 Share Posted May 16, 2017 If that highlighted part is a constant, then you can just use str_replace to find and replace all of them. http://php.net/manual/en/function.str-replace.php Link to comment Share on other sites More sharing options...
Badchip Posted May 16, 2017 Author Share Posted May 16, 2017 22 minutes ago, justsomeguy said: If that highlighted part is a constant, then you can just use str_replace to find and replace all of them. http://php.net/manual/en/function.str-replace.php So can I open the same "index.html" via PHP without the higlighted part? Would it be too much to ask an example? Link to comment Share on other sites More sharing options...
dsonesuk Posted May 17, 2017 Share Posted May 17, 2017 1) If *.html page it would have to be enabled to be treated as PHP. 2) The text in question has to used as text string to replace and echo out new link in PHP, OR ALL body content, applied to variable, and search and replaced. Another option would be to use mod_rewite in htaccess, it won't replace but redirect to required URL address. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 17, 2017 Share Posted May 17, 2017 You can use file_get_contents if you're trying to read a different file. If it's a .html file, and PHP is not configured to run in .html files, then it sounds like you're trying to open a different file than the PHP file. If you're trying to change the output that a PHP file will generate, the easiest way to do that is to use ob_start to start output buffering, and pass it a function that will run when the output buffer gets flushed. You can use that function to find and replace whatever you want before it gets sent to the browser. http://php.net/manual/en/function.ob-start.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now