Manipulate an HTML tag in a string using PHP

While working on a plugin for WordPress, I came along this requirement to add/append a variable CSS class to a HTML block. I have this variable in PHP that holds the class name. And another variable containing any arbitrary html tag block containing any content. Now, in a general case these variables may hold any content. I am not even sure if the HTML tag inside the $content variable already has the ‘class’ attribute defined, and so do I need to append a class name or add the attribute itself. So, using regular expression is just out of question because [...]

Getting a conversion table from UglifyJS

Getting a conversion table from UglifyJS First of all UglifyJS ( is an awesome tool. Helps me a lot with formatting, minfying and many other tasks when it comes to packing JavaScript for my projects. There had been a big and complex JavaScript code that had some variables prefilled via the PHP output. On mangling/compressing all the Javascript Code and variables using UglifyJS, I stumbled upon an issue. Now that all the variables had been mangled, the PHP at the backend had no idea about the new mangled names. To reconnect the Javascript to the backend PHP, I manually needed [...]