Skip to content
Advertisement

Category: Questions

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

PHP equivalent of friend or internal

Is there some equivalent of “friend” or “internal” in php? If not, is there any pattern to follow to achieve this behavior? Edit: Sorry, but standard Php isn’t what I’m looking for. I’m looking for …

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

Parsing domain from a URL

I need to build a function which parses the domain from a URL. So, with http://google.com/dhasjkdas/sadsdds/sdda/sdads.html or http://www.google.com/dhasjkdas/sadsdds/sdda/sdads.html it should …

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

Advertisement