Using PHP to convert css to inline style code

I am trying to write a php script that will take find the path of a webpage or a url, and convert the css from the server or local folder to inline code. I’ve looked pretty much all over the internet and looked for many solutions that could help me do this and done helped so far.

I have several <div>'s in my page all linking to a css code called general.css
For e.g.

<div class="sys_main_logo" style="">
		
<div class="sys_ml">

<div class="sys_ml_wrapper">

I want it to be able to convert to the properties of the css it’s linked to to inline code
for e.g.

<div style="position: relative; z-index: 56; background-color: #f4f4f4;>

Is this possible to write, can somebody assist me with this please? Thanks

Why do you want to take code where the HTML and CSS are nicely separated in their own files the way they should be and jubmle the two together into the one file? The style attribute is only there to use for testing styles prior to moving them into the external stylesheet. You shouldn’t be delivering live web pages that contain any style attributes - you should replace them all with classes and define those classes in the CSS file - now if you were asking how to do the opposite of what you are asking for it would make a lot more sense although it is far simpler to do it once manually rather than every time via PHP.

It’s because i’m trying to send the webpage as an e-mail, and i will have future webpages to send as e-mails as well so i need a PHP code that will take out the <a href> links and turn all css links into inline style code. I already have a code where it removes all <a href> links. Can i have help with this please?