I’ve got XAMPP installed on my Windows 7 Computer. I’ve been developing on it for a while now but my development has come to a grinding halt because XAMPP is rendering my PHP pages really slowly. It’…
Adding PostgreSQL support to already installed PHP
I have php-5.3.6 and postgresql installed in my Fedora 13. But it seems that postgresql support is not enabled in php. My phpinfo() page doesn’t show any PostgreSQL section, neither pdo_pgsql section. …
Split string on dots not preceded by a digit without losing digit in split
Given the following sentence: I want preg_split() to give this: I am using: But this gives me: As you can see, the last character of each sentence is removed. I know why this happens, but I don’t know how to prevent it from happening. Any ideas? Can lookaheads and lookbehinds help here? I am not really …
array_uintersect() gives unexpected results when callback only returns 0 or 1
I have a custom callback in my array_uintersect() call because I need to case-sensitively compare strings in two elements while comparing rows between two multi-dimensional arrays. OUTPUT I can’t understand why this code doesn’t produce the correct output which should be an array with “BR…
Standard Practices in Detecting Mobile Devices and Feeding Pages in PHP and jQuery
I see that mobile versions of websites often begin with an “m.” (e.g. http://m.accuweather.com). I’d like to redirect my mobile users to http://m.mysite.com so that I can display a different page. What’s the standard practice way to feed mobile devices the mobile version of a site? Doe…
PHP directory separators, forcing forward slash; non-intrusive
Whenever I work with PHP (often) I typically work on a Windows box, however I (try to) develop platform agnostic applications; one major point of issue being the use of directory separators. As many …
PDO connection works from command line, but not through Apache?
I have a very simple test script: When I execute this script from the command line, it works perfectly: But when I access the exact same script through my web browser, it says: I’ve tried var_dump on the error, and the message is: “SQLSTATE[HY000] [2003] Can’t connect to MySQL server on R…
Modulus in a PHP loop
I’m currently checking whether an entry in a loop is the third iteration or not, with the following code: How can I check if the loop is in its second and not its third iteration? I have tried $i % 2 == 1 to no avail. Answer Modulus checks what’s the leftover of a division. If $i is 10, 10/2
why are arabic numbers (١٢٣) not accepted in textboxes as real numbers?
while developing one of my sites, i noticed that if I enter arabic numbers (١٢٣), they are not interpreted as real number values. Then, I tested a few other sites only to find that they also don’t accept arabic numbers. The problem is, my client seems to require this functionality (accepting arabic numb…
Altering Title on Drupal Node Delete Confirmation Form
When you attempt to delete a node in Drupal, you’re taken to a confirmation page whose title is… Are you sure you want to delete {title of node}? I’m attempting to alter the title of this page …