How To Laid Upwardly Global Constants Containing Arrays Using Codeigniter?
You tin role Codeigniter's constants file to shop global arrays which tin hold upwardly used inwards multiple controllers or whatever where inside your codeigniter's projection scope.
Problem: Apparently, constants can't concord arrays.
Solution: You tin serialize your array in addition to and thence position it into the constant.
For example,
Ref: http://stackoverflow.com/questions/1290318/php-constants-containing-arrays
Sumber http://developer-paradize.blogspot.com
Problem: Apparently, constants can't concord arrays.
Solution: You tin serialize your array in addition to and thence position it into the constant.
For example,
# define constant, serialize array define ("FRUITS", serialize (array ("apple", "cherry", "banana"))); # role it $my_fruits = unserialize (FRUITS);You tin shop it every moment a JSON string inwards a constant. And application indicate of view, JSON tin hold upwardly useful inwards other cases.
define ("FRUITS", json_encode(array ("apple", "cherry", "banana"))); $fruits = json_decode (FRUITS); var_dump($fruits);It may exists other efficient ways to shop global arrays inwards Codeigniter. Suggestions volition hold upwardly appreciated. :)
Ref: http://stackoverflow.com/questions/1290318/php-constants-containing-arrays
Sumber http://developer-paradize.blogspot.com
Comments
Post a Comment