A very basic regex-based Markdown parser. Supports the
following elements (and can be extended via Slimdown::add_rule()
):
- Headers
- Links
- Bold
<?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 | |
$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 |
A very basic regex-based Markdown parser. Supports the
following elements (and can be extended via Slimdown::add_rule()
):
<?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 | |
// 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; |
, 70683 | |
the 63919 | |
and 51696 | |
of 34618 | |
. 26145 | |
to 13560 | |
that 12915 | |
: 12721 | |
in 12667 | |
he 10420 |
<?php | |
class FacebookBase { | |
public static $curlOpts = array( | |
CURLOPT_CONNECTTIMEOUT => 10, | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_TIMEOUT => 60, | |
CURLOPT_USERAGENT => 'facebook-php', | |
); |
<?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:
<?php | |
// Type casting is easy on weak languages | |
$a = (object) (array) (object) (array) (object) ["foo" => "bar"]; | |
// PHP will happily iterate over an object (like Javascript) | |
foreach($a as $key => $value) { | |
print "$key = $value" . PHP_EOL; | |
} |