Yes you can use php for your script. If you write a script in php, use the '<?' and '?>' start and end tag. Then, if your file is named sample.php, run it with 'php -f sample.php'.
If you want to execute a command in php, use the function 'exec' of 'passthru' depending on the result you want to get.
Anyway, using php is up to your choice. It certainly supports text filtering, but with sed you can write such filters much faster, so maybe learning it could be a good thing.