Remove specific HTML tags using PHP

There are times when you want to remove a specific HTML tag from an HTML block of text. This could be an anchor(<a/>>) or an image(<img/>) perhaps. You can use preg_replace to do this quite quickly and efficiently. Remove an anchor: [code lang=”php”] $content = “Sample text Our anchor. Etc Read more…

By Andrew Odendaal, ago

Refresh User Data in Joomla

I was busy with a custom component in Joomla, and it stored it’s own user_details based off of the main users table, but if the details were changed then I needed the system to update the session to reflect the changes. This is what I did: $user = JFactory::getUser(); $session Read more…

By Andrew Odendaal, ago

Extract email addresses from a string – PHP

Sometimes you need to extract multiple email addresses from a string and the following function will make all your dreams come true. [code lang=”php”] function extract_emails_from($string){ preg_match_all(“/[\._a-zA-Z0-9-][email protected][\._a-zA-Z0-9-]+/i”, $string, $matches); return $matches[0]; } [/code] ..and this is how you use it: [code lang=”php”] $text = “this is some text and here Read more…

By Andrew Odendaal, ago

Actionscript 2 & PHP Data Transfer

In the below example we will use Actionscript 2 to call a remote PHP file that will return data to it. It is a simple way of transferring data between the server and client. Actionscript 2 Code: [code lang=”actionscript”] callRemoteFile = function(ourVariable:String) { var result_lv:LoadVars = new LoadVars(); result_lv.onLoad = Read more…

By Andrew Odendaal, ago