Created
December 25, 2019 12:01
-
-
Save Shipu/5f85a3a56890a297590e8fda0c8a8b60 to your computer and use it in GitHub Desktop.
String with function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function day($value) { | |
return date('d', strtotime($value)); | |
} | |
function equal($one, $second) { | |
return $one == $second; | |
} | |
$singleData = [ | |
"create_at" => "'2019-10-5'", | |
"updated_at" => "'2019-10-10'" | |
]; | |
$string = "equal(day(create_at) * 2, day(updated_at))"; | |
$result = eval('return '.str_replace(array_keys($singleData), array_values($singleData), $string).';'); | |
var_dump($result); // return true; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment