Hi everyone,
Just had a quick question, ( I am not hard-core programmer just know my way around ).
I have some PHP that runs in the back of my site that deletes stuff from my html before rendering, Like line breaks and comments to render smaller HTML it uses preg_replace() and str_replace() to do so.
What I am wanting to do is something which I feel should be possible but need to know how.
I have a
<h2>This is the title</h2>
On my page and I want to add the following and make it looks like this:
<h2 id="this-is-the-title">This is the title</h2>
I worked for hours this morning trying to work it out but failed to do anything all I can do is id="1" and + 1 every time and this is not what I want I want it to read the h2 and replace special char and spaces with -.
Is there a way of doing this? Here is a couple of my preg_replaces and str_replaces already thee.
$start_buffer = preg_replace('/" style=/', '"style=', $start_buffer);
$start_buffer = preg_replace('/" class=/', '"class=', $start_buffer);
$start_buffer = str_replace("; }", "}", $start_buffer);
$start_buffer = str_replace("{ ", "{", $start_buffer);
As you can see all this is really doing is removing spaces that are not required.
Any help what so ever will be greatly appreciated.