You generally don't want to remove packages like this in pieces since there's typically dependencies that you're skipping over. Better to do this removal all at once like so:

$ rpm -e $(rpm -aq | grep php)

Better still I would encourage you to use yum to do this vs. RPM.

$ yum remove $(rpm -aq | grep php)

Even better then these would be to figure out a pattern that matches all the PHP packages and tell YUM to remove based on the pattern . Yes YUM is aware of regular expressions.

$ yum remove 'php*'

You'll need to make sure that your entire list of packages will fit on the command line but doing this using xargs or individually is wrought with problems, if you tell rpm to remove 1/2 of the PHP related packages in one command, followed by another rpm command with the rest.