Created
April 20, 2016 20:13
-
-
Save sheryarshirazi/feff60364649799af644011a92cdba29 to your computer and use it in GitHub Desktop.
Find Constant Array key Names
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 namespace yourName; | |
/** | |
* return constant array key | |
* @param constant $const constant array name | |
* @param int $index index of constant array key value (in my case its int) | |
* @return string key name (string in my case) | |
*/ | |
function getConstantArrayNames($const, $index) { | |
$x = get_defined_constants(true); | |
foreach ($x['user']['yourName\\'.$const] as $key => $value) { | |
if ($value == $index) | |
return $key; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment