Creating a static array in php

Status
Not open for further replies.
O

ooen

This is what I want to do. There is a list of directories that I want to store in an array, but I want to run the routine only once to create the array, and I want to make a static reference so that I can just keep referencing it. How can I do this?
 

alexandru

Yellow Belt
ooen said:
This is what I want to do. There is a list of directories that I want to store in an array, but I want to run the routine only once to create the array, and I want to make a static reference so that I can just keep referencing it. How can I do this?
If you want to run a routine only once to create an array all you have to do is
Code:
if (!isset($my_nice_array)){
  // routine to populate the array here...
  ...
}
but looking at that article I intend to believe that what you are actually trying to achieve is making "search engine friendly" URLs. If that is the case, these two articles might explain a bit better the subject:
http://www.sitepoint.com/article/search-engine-friendly-urls/
http://www.devshed.com/c/a/Apache/Search-Engine-Friendly-URLs-with-mod-rewrite/

--
Alex
Web Hosting & Domain Names UK
Webmaster Forums
Internet Access Web Hosting
 
O

ooen

I actually read both articles while back :) . The problem is that this is not good enough if you want to create descriptive URL strings; this is how I came up with a solution I presented in the paper. However, I didn't know how I can create the array only once in php. Now I know ... Thanks :) .
 
Status
Not open for further replies.
Top