Skip to content

Tag: php

Ignore case sensitivity when comparing strings in PHP

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…

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

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

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…