Skip to content

Instantly share code, notes, and snippets.

Chris De David christoferd

Block or report user

Report or block christoferd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@christoferd
christoferd / RoundDown2DemialPlaces.php
Last active Feb 13, 2018
PHP: Round a number down to two decimal places
View RoundDown2DemialPlaces.php
/**
* Custom function to round down to the nearest lowest number at 2 decimal places.
* e.g: 1.006 rounds down to 1.00
* Warning: Do not use PHP_ROUND_HALF_DOWN;
* round(0.006, 2, PHP_ROUND_HALF_DOWN) does not round down to 0
*
* @param $value
* - Must be numeric
* - Must be a positive value
* @return float
@christoferd
christoferd / wordWrapAtCharacter.php
Last active Jan 2, 2016
String/Text Word Wrap at a certain character. First created to wrap a long CSV list.
View wordWrapAtCharacter.php
function wordWrapAtCharacter($str, $minWidth = 200, $char = ',', $lineBreak = "\n")
{
// prev pos
$marker = 0;
// char pos
$pos = false;
if($minWidth+$marker < strlen($str))
{
$pos = strpos($str,$char,$minWidth+$marker);
}
@christoferd
christoferd / gist:7394561
Last active Dec 27, 2015
Create plain Text table from Array, or Array of Arrays. Great for dumping database table data to text only logs or display. Supports vertical single record display, and multi row (array of arrays) display. - 11-Nov-2013 Added Hanlde Empty Array
View gist:7394561
/**
* Create plain Text table from Array, or Array of Arrays.
* Great for dumping database table data to text only logs or display.
* @use String::textTableFromArray($myArrayOfArrays,'My Multi Row Table',true); // multiple records/array
* ArrayHelper::textTableFromArray($simpleKeyValArray,'A Single Record',false); // single row, vertical view
* @requires String::humanize() ... or just remove/override it.
*
* @param $arr
* @param string $tableTitle
* @param bool $horizontalDisplay
View gist:5679502
<div class="row">
<div class="span4">...</div>
<div class="span4 offset4">...</div>
</div>
You can’t perform that action at this time.