Skip to content

Instantly share code, notes, and snippets.

View jonathanlaf's full-sized avatar

Jonathan Lafleur jonathanlaf

View GitHub Profile
@jonathanlaf
jonathanlaf / getClosestLowerValue.php
Last active August 14, 2018 12:54
[Closest value operator] Get closest value (of an array) before a given one #php #operand
<?php
function valueExpected ($analyse, $expect, $strict = false)
{
if ($strict)
{
if ($analyse === $expect)
{
return '<span style="background-color:darkolivegreen; color:darkgrey;">Received : ' .
$analyse .
', Expected : ' .
@jonathanlaf
jonathanlaf / convertSameCaracterToSameAscii.php
Last active August 14, 2018 12:53
[Keyboard char to Ascii] Take care of different ASCII Code returned by a single caracter depending on Keyboard layout. #encoding #php #ascii
<?php
/*
* Accept array or string
*/
function convertSameCaracterToSameAscii($string)
{
$tab_chr = array() ;
for($control = 0; $control < 32; $control++) {
if ($control != 9 && $control != 10) {
$tab_chr[]= chr($control) ;