Preg_Replace all strings between two tags
For those of you who use Preg_Replace. Preg_replace is a function that uses regular expressions to search and replace a string.
Knowledge base / Since 1999
Practical Personal Home Page tutorials, troubleshooting notes and implementation guides from real projects.
Advanced search21 entries / Personal Home Page
Clear filters
For those of you who use Preg_Replace. Preg_replace is a function that uses regular expressions to search and replace a string.
Just a quick note on how to format a given filesize and to reduce the display output to a small string, eg: 196 bytes : displays as => "196 bytes" 12945 bytes : displays as => "12 Kb" 1478515 bytes : displays as => "1 Mb" 8798745455 bytes : displays as => "8 Gb"
This is intended for activity/session durations and although I usually get MySQL to do the date/time calculations, there are times when we have to do with PHP. This is the shortest way I know to properly convert seconds into total hours, minutes and seconds (taking into account regional settings and without using a dat...
So I know it's quite a long title but I'm not sure what I'll be searching next time. It has taken me a lot longer than I thought it would mostly out of frustration and the inability to know exactly what I'm looking for... always difficult. After a cup of tea the solution was glaringly obvious, just do a primary school...
Do you hate sites that do not have a search feature? I do. I think it defeats the purpose of cramming information endlessly in cyberspace. So we want to give a search engine to our users. This sounds really simple, we could try: $search_term_esc = AddSlashes($search_term); $sql = "SELECT * FROM Content WHERE content_bo...
This is a note to myself but also to anyone out there who's spent as long as I did looking for a solution to this. Maybe it's just me but this is the scenario: Joomla works fine with international characters A Module Extension I wrote for Joomla! displayed funny characters. The Joomla! articles were displaying the corr...
Quick tip or note to self: How to get yesterday's date irrespective of date format or daylight savings time. $today=date("Y-m-d"); $yesterday = date('Y-m-d', mktime(0, 0, 0, date("m") , date("d") - 1, date("Y")));
I've decided to put something in here as it took me an age to find out how I could do it. This is when using a MySQL query within a PHP script. The process is used often to do a statistics table or top ten chart of your data (eg. movies, music, etc). My aim is to do the following: retrieve data from a table, count the...
I'm beginning a list as I've just spent an age trying to get PHP output to create a text file. Then my client showed me how she then opens the text file in Excel, so I said we could get the script to do that instead.PHP to TXT header('Content-Type: text/plain; charset=utf-8'); header('Content-Disposition: attachment; f...
Working principle
This site exists as a practical knowledge base built from real-world experience across systems, platforms, and technologies since 1999. Much of the content documents solutions, edge cases, and working patterns that were learned through investigation where documentation was incomplete or absent, and is shared to reduce the same friction for others.
Protected notes
Log in for protected notes and any private client projects assigned to your account.