Skip to content

Instantly share code, notes, and snippets.

@PascaleBeier
Created January 12, 2017 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PascaleBeier/4f6194f8f5fe77683d1ec15b93a55b6e to your computer and use it in GitHub Desktop.
Save PascaleBeier/4f6194f8f5fe77683d1ec15b93a55b6e to your computer and use it in GitHub Desktop.
Strip HTML Attributes from File
#!/usr/bin/env php
<?php
$openedFile = file_get_contents(__DIR__.'/'.$argv[1], 'r');
$convertedString = preg_replace('/\s(color|size|class|id|style)="[^"]+"/', '', $openedFile);
$newFile = fopen(__DIR__.'/'.$argv[2], 'w');
fwrite($newFile, $convertedString);
fclose($newFile);
@PascaleBeier
Copy link
Author

PascaleBeier commented Jan 12, 2017

Strip HTML Attributes from File

Usage

In a terminal:

php convert.php [input] [output]

Example

php convert.php example.sql example-without-html-attrs.sql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment