Last active
January 1, 2016 08:19
-
-
Save tegansnyder/8117109 to your computer and use it in GitHub Desktop.
Format the output of the n98-magerun.phar config:get web/ to a csv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| n98-magerun url formater to CSV | |
| usuage: n98-magerun.phar config:get web/ | php n98-urls-to-csv.php > csv-of-urls.csv | |
| */ | |
| $str = stream_get_contents(fopen("php://stdin", "r")); | |
| $str = str_replace("+","",$str); | |
| $str = str_replace("-","",$str); | |
| $str = str_replace("|",",",$str); | |
| $str = str_replace(" ","",$str); | |
| $str = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $str); | |
| $str_array = explode("\n", $str); | |
| foreach ($str_array as $nstr) { | |
| if (!empty($nstr)) { | |
| $nstr = rtrim($nstr, ','); | |
| $nstr = ltrim($nstr, ','); | |
| echo $nstr . PHP_EOL; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Scratch that looks like n98-magerun has a nice feature included to do this:
n98-magerun.phar config:get web/ --magerun-script