Skip to content

Instantly share code, notes, and snippets.

@setola
Created July 14, 2017 15:22
Show Gist options
  • Select an option

  • Save setola/2ce4ed4d196001af60e2c153d4d6770d to your computer and use it in GitHub Desktop.

Select an option

Save setola/2ce4ed4d196001af60e2c153d4d6770d to your computer and use it in GitHub Desktop.

Revisions

  1. setola created this gist Jul 14, 2017.
    21 changes: 21 additions & 0 deletions index.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    <?php

    $inHandler = fopen("in.csv", "r");
    $outHandler = fopen("out.txt", "w");

    $row = 0;

    while (($data = fgetcsv($inHandler, 1000, ",")) !== FALSE) {
    $row++;
    if (1 == $row) continue;
    $data = array_map(function ($item) {
    return str_replace('http://gsped.com', '', $item);
    }, $data);
    fwrite($outHandler, vsprintf('RewriteRule "^%s$" "%s" [R=%s,L]' . PHP_EOL, $data));
    }


    fclose($inHandler);
    fclose($outHandler);

    printf("wrote %s lines" . PHP_EOL, $row);