Reputation:
Im trying to make a decompiler, I finaly managed to decompile the code to a string, but I want to add a linebreak after the character ";" so I tried:
str_replace(";", ";\n", $data);
file_put_contents($name.'.php', $data);
But it doesn't seem to create a linebreak
Upvotes: 1
Views: 86
Reputation: 352
for new line break use following syntax:
$data = str_replace(";", ";\r\n", $data);
for Apache server, we have to always use \r before \n for line break.
Upvotes: 2
Reputation: 6830
If you are on windows, you might want to try \r\n
instead of just \n
, or maybe look into the PHP constant PHP_EOL
which contains
The correct 'End Of Line' symbol for this platform. Available since PHP 4.3.10 and PHP 5.0.2
"\r\n"
would still be the best solution for cross system compatibility though. More info about that can be found in this question
Upvotes: -1
Reputation: 670
You Should try
str_replace(";", ";\n\r", $data);
file_put_contents($name.'.php', $data);
And Try to open in notepad++ or sublime Text
Upvotes: 0
Reputation: 15537
You're not assigning the output of str_replace to anything. Also, if you're looking at your file in Windows, you should also add a carriage return "\r"
.
Upvotes: 0
Reputation: 1971
You should do this :
$data = str_replace(";", ";\r\n", $data);
The str_replace functions returns a string, it does not modify the string passed in parameters.
More info here:
http://php.net/manual/fr/function.str-replace.php
Upvotes: 2