A PHP array can have arrays for its elements. And those arrays can have arrays and so on and so forth. Is there a way to find out the maximum nesting that exists in a PHP array? An example would be a function that returns 1 if the initial array does not have arrays as elements, 2 if at least
How to get a variable name as a string in PHP?
Say i have this PHP code: $FooBar = “a string”; i then need a function like this: print_var_name($FooBar); which prints: FooBar Any Ideas how to achieve this? Is this even possible in PHP?
Enumerations on PHP
I know that PHP doesn’t yet have native Enumerations. But I have become accustomed to them from the Java world. I would love to use enums as a way to give predefined values which IDEs’ auto-completion …
Best practices to test protected methods with PHPUnit
I found the discussion on Do you test private method informative. I have decided, that in some classes, I want to have protected methods, but test them. Some of these methods are static and short. Because most of the public methods make use of them, I will probably be able to safely remove the tests later. But for starting with
Can’t use certain characters in a regex
if(!eregi(“^([0-9a-z_[]*- ])+$”, $subuser)) $form->setError($field, “* Username not alphanumeric”); Can anybody tell me why it is not allowing characters such as – and *? if(!eregi(“^([0-…
In PHP, how do you change the key of an array element?
I have an associative array in the form key => value where key is a numerical value, however it is not a sequential numerical value. The key is actually an ID number and the value is a count. This …
PHP syntax highlighting [closed]
I’m searching for a PHP syntax highlighting engine that can be customized (i.e. I can provide my own tokenizers for new languages) and that can handle several languages simultaneously (i.e. on the …
PHP Access Control System
I am part of a team creating a web application using PHP and MySQL. The application will have multiple users with different roles. The application will also be used in a geographically distributed …
How can I change a file’s extension using PHP?
How can I change a file’s extension using PHP? Ex: photo.jpg to photo.exe Answer In modern operating systems, filenames very well might contain periods long before the file extension, for instance: PHP provides a way to find the filename without the extension that takes this into account, then just add the new extension:
Calling Python in PHP
I have a Python script I recently wrote that I call using the command line with some options. I now want a very thin web interface to call this script locally on my Mac. I don’t want to go through the minor trouble of installing mod_python or mod_wsgi on my Mac, so I was just going to do a system()