I’m trying to compare words for equality, and the case [upper and lower] is irrelevant. However PHP does not seem to agree! Any ideas as to how to force PHP to ignore the case of words while comparing them? Is there a way to carry out the replace even if the case is different? Answer Use str_ireplace to…
Tag: php
How would I skew an image with GD Library?
I want to skew an image into a trapezoidal shape. The left and right edges need to be straight up and down; the top and left edges need to be angular. I have no idea what the best way to do this is. I’m using GD Library and PHP. Can anyone point me in the right direction? Thanks, Jason Answer
[HTML/CSS/JavaScript/PHP]: In which order code must be written?
While writing code in a file that would comprise of PHP, HTML, CSS & JavaScript, in what order each must appear? What are the best practices for separating the presentation and the logic? Sometimes external .js and other files are using in the link tag. Where these link tags must appear? Answer This doesn…
MySQL datetime fields and daylight savings time — how do I reference the “extra” hour?
I’m using the America/New York timezone. In the Fall we “fall back” an hour — effectively “gaining” one hour at 2am. At the transition point the following happens: it’s 01:59:00 -04:00 then 1 …
How do I remove a comma off the end of a string?
I want to remove the comma off the end of a string. As it is now I am using but that only removes the last character of the string. I am adding the string dynamically, so sometimes there is no comma at the end of the string. How can I have PHP remove the comma off the end of the
Duplicate a record in MySQL
I have a table and I want to duplicate specific rows in the table. I know this is not the best way to do things but we are looking for a quick solution. Here’s something harder than I initially thought, all I need to do is copy an entire record to a new record in an auto-increment table in MySql
MySQL: Join query across multiple databases located on different servers
In SQL Server there is a way to join tables from multiple sql servers by using link tables. I wonder whether is it possible to do the same? I am using PHP, does PHP provides this kind of facilities? Answer It isn’t necessarily easy, nor pretty, but this article gives some solutions to your problem: http…
How to get the first item from an associative PHP array?
If I had an array like: And I wanted to get the first item out of that array without knowing the key for it, how would I do that? Is there a function for this? Answer reset() gives you the first value of the array if you have an element inside the array: It also gives you FALSE in case
Pattern Match on a Array Key
I need to get the stock values out of this array: I need to pattern match on this array, where the array key = “stock” + 1 wildcard character. I have tried using the array filter function to get every other value on the PHP manual but the empty values seem to throw it out. I tried alot of differen…
netcat “Connection refused” on localhost
I’m trying to get a value from a netcat connection started at a php file, but it dies with: I don’t know why but it works well if I ssh it as apache user (www-data), this is what I’ve done: 1) Start an endless loop serving a date with a little delay: 2) Check if is working: 3) Create /var/ww…