I’m working on a site with multiple subdomains, some of which should get their own session. I think I’ve got it worked out, but have noticed something about cookie handling that I don’t understand. I don’t see anything in the docs that explains it, so thought I would see if anyone here has some light to shed on the question.
Tag: php
How find the source code for an eval’d function in PHP?
I am trying to find a way to get the source code for (user defined) PHP functions in a string. For normal code this is easy, using reflection I can find the file and line numbers where the function is defined; then I can open the file and read the function source code. This will not work if a function
MySQL Prepared statements with a variable size variable list
How would you write a prepared MySQL statement in PHP that takes a differing number of arguments each time? An example such query is: The IN clause will have a different number of ids each time it is run. I have two possible solutions in my mind but want to see if there is a better way. Possible Solution 1
Algorithm for generating a random number
I’m looking to generate a random number and issue it to a table in a database for a particular user_id. The catch is, the same number can’t be used twice. There’s a million ways to do this, but I’m hoping someone very keen on algorithms has a clever way of solving the problem in an elegant solution in that the
How to remove duplicate values from an array in PHP
How can I remove duplicate values from an array in PHP?
How do I format a number to a dollar amount in PHP
How do you convert a number to a string showing dollars and cents? eg: 123.45 => ‘$123.45’ 123.456 => ‘$123.46’ 123 => ‘$123.00’ .13 => ‘$0.13’ .1 => ‘$0.10’ 0 …
PHP replaces spaces with underscores
I have the problem, that PHP replaces all spaces with underscores in POST and GET variables. For example if I have the URL: http://localhost/proxy.php?user name=Max the browser will convert it to http://localhost/proxy.php?user%20name=Max. But if I give the $_GET parameters out, the key is not user name but user_name (note the underscore)! Is there any possibility to change this behaviour? Answer
Increase days to php current Date()
How do I add a certain number of days to the current date in PHP? I already got the current date with: Just need to add x number of days to it Answer php supports c style date functions. You can add or substract date-periods with English-language style phrases via the strtotime function. examples… or
Regex for names
Just starting to explore the ‘wonders’ of regex. Being someone who learns from trial and error, I’m really struggling because my trials are throwing up a disproportionate amount of errors… My experiments are in PHP using ereg(). Anyway. I work with first and last names separately but for now using the same regex. So far I have: Any length string
Is there a way to find out how “deep” a PHP array is?
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