Skip to content

Instantly share code, notes, and snippets.

View xmoonlight's full-sized avatar

xmoonlight

View GitHub Profile
@xmoonlight
xmoonlight / exchange.php
Last active September 17, 2017 14:38
Small currency exchange function (PHP, stand-alone)
<?php
function exchange($amount,$give,$get) {
$exchanges=[
'USD:RUB'=>60,
'RUB:USD'=>1/60,
];
$in=[$give.':'.$get=>$amount];
$key=key($in);
if ($amount>0 && $exchanges[$key]) {
@xmoonlight
xmoonlight / fuzzyChain_test.php
Last active July 27, 2022 12:18
Substring search in text with fuzzy tail (PHP): fuzzyChain
<?php
function fuzzyChain($search,$where,$skipFirst=0) {
/********************************
FuzzyChain
©Copyright,2017 @xmoonlight
https://github.com/xmoonlight
********************************/
$spaces="\s";
$sWords=preg_split("/[".$spaces."]+/iu",$search);
$wWords=preg_split("/[".$spaces."]+/iu",$where);