PhotoDateChanger
Easily change the dates and times on your photos and videos
Click here for more info about the app
VocabReminder
English dictionary with notifications so you won't forget what you're studying!
Click here for more info about the app
VocabQuiz
The app that quizzes and scores you on your vocabulary!
Click here for more info about the app

Posts Tagged with "Php"

XPath with HTML in PHP One Liner

Here is a one liner for using XPATH with HTML in PHP $doc = new DOMXPath(@DOMDocument::loadHTML(file_get_contents("https://www.reddit.com/r/PHP/")...


How to Calculate Age with PHP

Calculate age in PHP $your_birthday = '1982-08-29'; $difference = date_diff(date_create(), date_create($your_birthday)); $age = $differe...


How to Use Named Variables with Postgres and PHP PDO Driver

You can write reusable scripts with Postgres by taking advantage of named variables. A named variable starts with a `:` in your sql script. Here i...


How to Get a Random Item from an Array in PHP

Use this snippet for grabbing a random item from an array in php $fruits = ['apple', 'banana', 'carrot', 'date', 'elderberry']; echo array_ran...


Connect to Postgres on Heroku using DATABASE_URL Config Var with PHP and PDO

Unfortunately PHP's PDO constructor doesn't take a database connection url (in a format that Heroku makes available as a config var) as an argument. I...


How to Slugify a String in PHP

Here is a snippet for generating a URL friendly slug in PHP function slugify($string){ return strtolower(trim(preg_replace('/[^A-Za-z0-9-]+/...


How to Generate a UUID in PHP

Here is a little snippet for generating a UUID in PHP function uuid(){ $data = random_bytes(16); $data[6] = chr(ord($data[6]) & 0x0f | 0x4...


Apache Rewrite Rule for Mapping to index.php in Sub Folders

Below is an example URL structure with rewrite rules using an Apache .htaccess file. GET /a/ => a/index.php GET /a/b/ => a/b/index.php...


Regex for Extracting URLs in Plain Text

Here is a Regex for extracting URLs from text. However, these links will not already be hyperlinked or source attribtues from images or iframes. T...


I Just Published My First PHP Package HTMLXPATH

I just wrote and published my first PHP package on Packagist.com. It's available on [packagist.org](https://packagist.org/packages/htmlxpath/htmlxpath...


Deploying Wordpress on Heroku

> This post is out of date - Heroku officially supports PHP now w/ buildpacks Heroku runs Apache version 2.2.22 PHP version 5.3.10 Deployi...


How To Increase or Change the File Upload Size in the PHP ini file for Wordpress

You need to find which configuration ini file has been loaded by PHP. The easiest way to do this is to run the phpinfo() function from the command l...


Installing Ruby on Rails 3, MySQL, Git, Ruby Enterprise Edition, Passenger (Mod_Rails) on Ubuntu with Rackspace Cloud.

Short and sweet. Here all the commands I run in this order to set up a brand new box. It usually takes about 10 - 15 minutes on a 256 MB RAM instance....


The Context of Markup vs Expressions of Equality in Determining the Meaning of Angled Brackets

In the Wordpress editor (html mode) you'll need to become friends with < and > if you plan on showing any code (php, html... xml, most languages...


How to Import/Export Your Wordpress Blogroll... er, Your Links

It's not immediately apparent how to import/export the links in your Wordpress blogroll. One would expect that the import/export tool, used to backup/...


How to Check if the Current Logged In User can Edit a Course in MOODLE Using the Has_capability Function

After an hour of fruitless searching through the docs and forums, I finally found an answer to my simple question, of course buried in the depths of t...


Moodle's Most Important Function Gets No Attention

Arguably the most important function in the Moodle API, is the create_course function. One would think... after all Moodle is an LMS. Courses are the...


Convert Array to Object in PHP

function array2obj($data) { return is_array($data) ? (object) array_map(__FUNCTION__,$data) : $data; } Source: <a href="http://www.se...


Get Child Categories of Parent Category on Single Post in Wordpress

I was hoping to find a function in the Wordpress API, that goes something like this... the_child_categories("Vermont"); // print Burlington,...


How To Flush Your Permalink Structure in Wordpress When Using Taxonomies ...or Wordpress Taxonomies Not Working Instead I See A 404 Page

I didn't know this, but because of a linking problem using custom taxonomies in Wordpress, I was forced to find out. If you create a new taxonomy, it...


My Review of Moodle 1.9 Extension Development

I wrote a review for Joseph Thibault's Moodle News on extension development for Moodle. The book is quite good and...


Why are PHP5 Namespaces Defined Using a Backslash?

Why are PHP namespaces defined using a backslash? It looks ugly. Unless of course, there is a good reason for the "\"? Does this namespaced code run m...


Install and Serve a Rails Application from PHP Subdirectory Using Apache, Phussion Passenger and Ruby Enterprise Edition

Here is how to install a Rails application out of a subdirectory (rather than as a subdomain) with the Apache web server(Apache2). In this example I'm...


Using the PHP Mail Function with Additional Headers

Pass a fourth parameter to the mail() function with the header information. <?php $to = "jane@example.com"; $subject = "Hello World!"; $body...


Generate MySQL Datetime Type Using PHP Date() Function

If you want to insert a datetime that matches the default mysql datetime type format use this date('Y-m-d H:i:s');...


PHP Paypal IPN Script

Simple script for posting a valid response back to Paypal service after a sale is completed using the Paypal Instant Checkout payment method. &l...


Listing Files and Directories with PHP

Listing all files and directories using PHP 5. <?php $files = array(); $dir = dir("."); while(false!==($file=$dir->read())): if(($file{0...


Highlight String in PHP

Function for highlighting text/strings in PHP. $content = file_get_contents("http://php.net/"); print highlight("PHP", $content); function hig...


Absolutize Relative Links Using PHP and Preg_Replace_Callback

I was in the market for a simple php script to replace hrefs with their absolute paths from scraped web pages. I wrote one myself. I used the preg_re...


Grab a Twitter Status without the Twitter API

Quick and dirty way to grab the users status messages without having to go through the twitter api (not having to authenticate that is). You can grab...


Mod_Python and Web.py on Ubuntu

Download First install mod_python for Apache and then restart/reload the server. apt-get install libapache2-mod-python /etc/init.d/apac...


TinyMCE Rich Text Editor: HELLO EDITOR Plugin Tutorial and Example

I wanted to create a button for the TinyMCE Rich Text Editor for Wordpress. It was tough to find good docs on the subject. There are a couple of usefu...


Deploy Sintra App on Ubuntu Using Apache2 and Phusion Passenger Module

Check it out http://sinatra.seanbehan.com/ This assumes Apache2 and the Phusion Passenger module have already been installed. If not you can get up to...


Ruby on Rails vs. PHP in a Nutshell

[youtube]http://www.youtube.com/watch?v=p5EIrSM8dCA[/youtube]...


Why Doesn't Google Offer Dedicated Virtual Hosting?

AppEngine is nice, but it's a little limiting. No cron jobs, filesystem use nor customization with third party libraries, software, databases, languag...


Postfix, ActionMailer and OpenSSL Fix on Ubuntu

If you run into problems using ActionMailer > 2.2, Postfix and OpenSSL while sending mail from your application, try changing the following: v...


Set Cron Job to Run Every Five Minutes for a Ruby on Rails Rake Task

First off you'll need to edit your cron file. Normally, the cron files are kept under /etc/cron.daily or /etc/cron.hourly but we can just use the comm...


Setting up a new ubuntu server with apache2, php, ruby on rails, rubygems, mysql, and git

Here are a list of commands to get up and running with Apache2 with Phussion Passenger for Rails, PHP5, MySQL5, Ruby on Rails with Gems, and the sourc...