A very basic regex-based Markdown parser. Supports the
following elements (and can be extended via Slimdown::add_rule()
):
- Headers
- Links
- Bold
<?php | |
$regions = array( | |
'Africa' => DateTimeZone::AFRICA, | |
'America' => DateTimeZone::AMERICA, | |
'Antarctica' => DateTimeZone::ANTARCTICA, | |
'Aisa' => DateTimeZone::ASIA, | |
'Atlantic' => DateTimeZone::ATLANTIC, | |
'Europe' => DateTimeZone::EUROPE, | |
'Indian' => DateTimeZone::INDIAN, | |
'Pacific' => DateTimeZone::PACIFIC |
<?php | |
// http://nob-log.info/2012/04/12/phper-filter-validate-email/ | |
$times = 10000; | |
$result = array(); | |
// preg_match | |
// regexp is stolen from: | |
// https://github.com/php/php-src/blob/master/ext/filter/logical_filters.c#L525 |
A very basic regex-based Markdown parser. Supports the
following elements (and can be extended via Slimdown::add_rule()
):
<?php | |
/** | |
* Download helper to download files in chunks and save it. | |
* | |
* @author Syed I.R <syed@lukonet.com> | |
* @link https://github.com/irazasyed | |
* | |
* @param string $srcName Source Path/URL to the file you want to download | |
* @param string $dstName Destination Path to save your file | |
* @param integer $chunkSize (Optional) How many bytes to download per chunk (In MB). Defaults to 1 MB. |
<?php | |
class FacebookBase { | |
public static $curlOpts = array( | |
CURLOPT_CONNECTTIMEOUT => 10, | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_TIMEOUT => 60, | |
CURLOPT_USERAGENT => 'facebook-php', | |
); |
<?php | |
// address to map | |
$map_address = ""; | |
$url = "http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=".urlencode($map_address); | |
$lat_long = get_object_vars(json_decode(file_get_contents($url))); | |
// pick out what we need (lat,lng) | |
$lat_long = $lat_long['results'][0]->geometry->location->lat . "," . $lat_long['results'][0]->geometry->location->lng; |
<?php | |
/** | |
* Count the number of working days between two dates. | |
* | |
* This function calculate the number of working days between two given dates, | |
* taking account of the Public festivities, Easter and Easter Morning days, | |
* the day of the Patron Saint (if any) and the working Saturday. | |
* | |
* @param string $date1 Start date ('YYYY-MM-DD' format) |
<?php | |
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); | |
ini_set('display_errors', 1); | |
function formatcurrency($floatcurr, $curr = 'USD') | |
{ | |
/** | |
* A list of the ISO 4217 currency codes with symbol,format and symbol order |
<?php | |
// input misspelled word | |
$input = 'carrrot'; | |
// array of words to check against | |
$words = array('apple','pineapple','banana','orange', | |
'radish','carrot','pea','bean','potato'); | |
// no shortest distance found, yet | |
$shortest = -1; |
This example uses techniques to implement a donation page with Stripe Checkout and PHP. It includes a variable amount input, quick-add amount buttons, basic form validation, ajax card charge, error handling on the response, UI for processing during submission, and ARIA accessibility enhancements.
If you use ExpressionEngine, make sure to include CSRF in your form and ajax post:
Add a hidden input to the form: