Skip to content

Instantly share code, notes, and snippets.

@ridvanbaluyos
ridvanbaluyos / regex-numbers.regex
Created August 11, 2015 10:38
Regex for Philippine Numbers
((\+[0-9]{2})|0)[.\- ]?9[0-9]{2}[.\- ]?[0-9]{3}[.\- ]?[0-9]{4}
or
((\+63)|0)[.\- ]?9[0-9]{2}[.\- ]?[0-9]{3}[.\- ]?[0-9]{4}
will match these:
+63.917.123.4567
+63-917-123-4567
+63 917 123 4567
+639171234567
private function checkQueryString()
{
if(!empty($_SERVER['QUERY_STRING']) && !preg_match('/^[\p{L}\p{P}\p{S}\p{N}\p{Z}\p{M}\p{Cyrillic}]+$/u', trim(urldecode($_SERVER['QUERY_STRING']))))
{
exit;
}
}
<?php
function generateMessageId()
{
return str_pad(rand(), 32, '0', STR_PAD_LEFT);
}
$mobile_number = '';
$client_id = '';
$secret_key = '';
$short_code = '';
@ridvanbaluyos
ridvanbaluyos / to_ordinal.php
Last active August 29, 2015 14:14
Converts a number into its Ordinal form.
/**
* This function converts a number into its ordinal format. If the input passed
* is not an integer, it will attempt to type cast it to integer.
* Note: check the edge case when the input is 0 (both for string and integer)
* Ref: http://stackoverflow.com/questions/3109978/php-display-number-with-ordinal-suffix
*
* @param Integer $number - the input. must be an integer
*
* @return String $abbreviation - the formatted number.
*