The popular open-source contract for web designers and developers by Stuff & Nonsense
- Originally published: 23/12/2008
- Revised date: 15/12/2013
- Original post
function extractCommonWords($string){ | |
$stopWords = array('i','a','about','an','and','are','as','at','be','by','com','de','en','for','from','how','in','is','it','la','of','on','or','that','the','this','to','was','what','when','where','who','will','with','und','the','www'); | |
$string = preg_replace('/ss+/i', '', $string); | |
$string = trim($string); // trim the string | |
$string = preg_replace('/[^a-zA-Z0-9 -]/', '', $string); // only take alphanumerical characters, but keep the spaces and dashes too… | |
$string = strtolower($string); // make it lowercase | |
preg_match_all('/\b.*?\b/i', $string, $matchWords); | |
$matchWords = $matchWords[0]; |
function $(q, parent) { return (parent || document).querySelector(q); } |
function string_limit_words($string, $word_limit) | |
{ | |
$words = explode(' ', $string, ($word_limit + 1)); | |
if(count($words) > $word_limit) | |
array_pop($words); | |
return implode(' ', $words); | |
} |
<?php | |
require_once('./config.php'); | |
if ($_SERVER['REQUEST_METHOD'] == 'POST') { | |
$postdata = file_get_contents("php://input"); | |
$event = json_decode($postdata); | |
if ($event->type == 'invoice.payment_succeeded') { | |
$customer_id = $event->data->object->customer; | |
$customer = Stripe_Customer::retrieve($customer_id); | |
$invoice = Stripe_Invoice::retrieve($event->data->object->id); |