Posts: 3,110
Location: Toronto, Ontario
|
Quote:
|
Hmmm. Sounds like there's a pretty steep learning curve. I might be better off with a language I already know...
|
It depends. If you are used to the "Java way" for example, it might be a bit of a change to do it the "PHP way". In PHP things are usually a bit simpler. In Java for example you might get a File, and then a FileReader, and then decorate it BufferedReader etc etc. In PHP I think it's much more straight forward. PHP itself is a very simple language, but it might take some time to make the change.
If the project *needs* to run on as many hosts as possible then PHP is a great choice. But some things you describe, like shared memory between requests, need special software anyway.
Quote:
|
But it sounds like you can use strings instead of integers to index arrays in PHP? How does that work? I know you could write a function to loop through the array until it finds a match, but is there a better method, out of the box?
|
In PHP arrays can be indexed by string or integer. And there is no difference between the two. Arrays are arrays, you can even mix integer keys with string keys. You can loop over arrays with a foreach construct.
Here's an example:
PHP Code:
$array = array( 'hello' => 'world', 0 => 'zero', 'chroder' => 'member', 99 => 'ninety nine' );
foreach ($array as $key => $val) { echo "$key: $val\n"; }
// hello:world // 0: zero // etc
See Arrays in the PHP manual for more examples and explanations.
|