Skip to content

Instantly share code, notes, and snippets.

View JaggedJax's full-sized avatar

William W JaggedJax

View GitHub Profile
@JaggedJax
JaggedJax / SSCC-18.php
Created October 4, 2017 20:34
Generate SSCC-18 barcode & verify SSCC-18 check digit
<?php
/**
* Generate and return an SSCC-18 barcode. DOES NOT include leading "00"
* Params can be passed as strings or ints and will be padded to proper length.
* @param string $next_serial_available
* @param string $extension
* @param string $gs1_prefix
* @param string $min_serial
* @param string $max_serial
@JaggedJax
JaggedJax / money_float.php
Last active November 3, 2015 23:26
Format number or string as a float
<?php
/**
* Take a number or numerical string and format as float
* Supports US and UK formats. Designed for money but will work with other formats as well.
* @param mixed $amount
* @param int $decimal_places
* @param int $round_mode
* @return float
*/
@JaggedJax
JaggedJax / stack_trace.php
Last active November 3, 2015 23:34
Simple human readable stack trace for PHP scripts or Web
<?php
/**
* Print out a stack trace from entry point to wherever this function was called.
* @param boolean $show_args Show arguments passed to functions? Default False.
* @param boolean $for_web Format text for web? Default True.
* @param boolean $return Return result instead of printing it? Default False.
*/
public static function stack_trace($show_args=false, $for_web=true, $return=false){
if ($for_web){
$before = '<b>';