Ok, reading a file using file_get_contents
and removing <?php
, <?
, and/or any ?>
tags, but I also want to remove all line breaks within the file. How can I achieve this?
For example a file like so:
<?php
$txt['dpmod_testing'] = 'Testing';
$txt['dpmodtitle_testing'] = 'My Testing Module';
$txt['dpmodinfo_testing'] = 'Just a Testing Module, nothing special.';
$txt['dpmoddesc_testing'] = 'Here is a description for this testing module that you will see within the Add Modules section![color=red]I can give myself credit for this module if I want to![/color][hr]And this text string also accepts BBC Code!';
?>
Should return this:
$txt['dpmod_testing'] = 'Testing';
$txt['dpmodtitle_testing'] = 'My Testing Module';
$txt['dpmodinfo_testing'] = 'Just a Testing Module, nothing special.';
$txt['dpmoddesc_testing'] = 'Here is a description for this testing module that you will see within the Add Modules section![color=red]I can give myself credit for this module if I want to![/color][hr]And this text string also accepts BBC Code!';
But instead I am getting this written to the file, when using file_put_contents
:
$txt['dpmod_testing'] = 'Testing';
$txt['dpmodtitle_testing'] = 'My Testing Module';
$txt['dpmodinfo_testing'] = 'Just a Testing Module, nothing special.';
$txt['dpmoddesc_testing'] = 'Here is a description for this testing module that you will see within the Add Modules section![color=red]I can give myself credit for this module if I want to![/color][hr]And this text string also accepts BBC Code!';
With 2 line breaks above and 2 line breaks also below. How can I remove all of these line breaks?
Here is the preg_replace I am using to remove the php tags from within the file, but how can this be modified to also keep the file the way it is, and remove all line breaks?
preg_replace(array('/<\?php/s', '/\?>/s', '/<\?/s'), array('', '', ''), $str);
Thanks guys :)