Skip to content

Instantly share code, notes, and snippets.

@raulinoneto
Last active June 9, 2020 03:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raulinoneto/c7764aa87b058492efe3981ae70703d2 to your computer and use it in GitHub Desktop.
Save raulinoneto/c7764aa87b058492efe3981ae70703d2 to your computer and use it in GitHub Desktop.
<?php
/**
* @var $initial int
* @var $end int
* @var $startEvent int
* @var $endEvent int
*/
function eventIsBetween($inital, $end, $startEvent, $endEvent):bool{
if ($startEvent > $end || $endEvent < $initial){
return false
}
for($i=$initial;$i>=$end; $i++){
if(isBetween($i, $initial, $end)){
return true;
}
}
return false;
}
/**
* @var $needle int
* @var $initial int
* @var $end int
*/
function isBetween($needle, $initial, $end):bool
{
return ($needle <= $end) && ($needle >= $initial);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment