Is there a way to use code something among the lines of:
in php? I've only found ways to do this in Jquery, but that's no use to me.
No you can't, because "hover" is a client-side event.
PHP as a server language can't check client actions.
The only way is using CSS for style event (changing color) or JS (like jQuery) for dynamic event.