Anti-Moronic Posted January 17, 2010 Share Posted January 17, 2010 Here's the trouble I'm having: I use regex quite a lot so I've decided to compile them into an array. Problem is, I have no idea how to access this array from within many different classes or functions. Is there I way I can give my entire app access to this by declaring someting *outside* all classes? Link to comment https://forums.phpfreaks.com/topic/188786-can-i-make-an-arrayvariable-available-everywhere-in-every-class-and-function/ Share on other sites More sharing options...
Buddski Posted January 17, 2010 Share Posted January 17, 2010 You could create a static class that holds the array class GlobRegex { public static $reg = array(....); } then you you access the regex in your functions using GlobRegex::reg[] Link to comment https://forums.phpfreaks.com/topic/188786-can-i-make-an-arrayvariable-available-everywhere-in-every-class-and-function/#findComment-996676 Share on other sites More sharing options...
Anti-Moronic Posted January 17, 2010 Author Share Posted January 17, 2010 Thanks again! is there any way of achieving this if I define my array like so: $regex[0] = '#regex1#'; $regex[1] = '#regex2#'; Link to comment https://forums.phpfreaks.com/topic/188786-can-i-make-an-arrayvariable-available-everywhere-in-every-class-and-function/#findComment-996679 Share on other sites More sharing options...
Anti-Moronic Posted January 17, 2010 Author Share Posted January 17, 2010 Sorry, I'm being stupid looking for the final solution. I've simply included a file with the array within a function I run all validations through. Thanks for you help. Link to comment https://forums.phpfreaks.com/topic/188786-can-i-make-an-arrayvariable-available-everywhere-in-every-class-and-function/#findComment-996683 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.