Tag Archives: php

RegEx: Compare two strings to find Alliteration and Assonance

would be possible to Compare two strings to find Alliteration and Assonance? i use mainly javascript or php Continue reading
Tagged , , | Leave a comment

Why is a `switch` considered a looping structure for the purposes of `continue`?

I just got bit by assuming the following:
foreach ($arr as $key => $value) {
  switch($key) {
    // ... some other cases
    default:
      continue;
      // ^== assumption: move on to the next iteration of the foreach
      //     actual PHP: treat
Continue reading
Tagged , , | Leave a comment

PHP money_format(); £ sign not GBP

I cannot work out how to get the currency symbol? At the moment I am using
setlocale(LC_MONETARY, 'en_GB');
money_format('%i', 1000);
Which give me the output
GBP1,000
But I want
£1,000
I have checked out the PHP manual… Continue reading
Tagged , | 4 Comments

Why are PHP errors printed twice?

Summary Amazingly I could find nothing about this on Google or SO. When I throw an exception in PHP it appears in my console twice, complete with error message and stack trace. The first time it’s printed it says “PHP… Continue reading
Tagged , , | Leave a comment

MySQL GROUP BY UNIX TIMESTAMP

I’m trying to fetch a number of rows from a MySQL database and group them by the day they were posted. End result I would like the following.. Monday -Article 1 -Article 2 -Article 3 Tuesday -Article 1 -Article 2… Continue reading
Tagged , , | 1 Comment

What is best practice when it comes to storing images for a gallery?

My question is not about storing images on disk or in DB. Images will be stored on disk Image path and other image data will be saved in database. Images will be given a unique filename Images will be stored… Continue reading
Tagged , , , | 2 Comments

vBulletin API to get member list and add member via PHP+cURL

Looking to do two things with the vBulletin API (v4.1.3) via PHP+cURL: Get member list. Add new user. I am having a hard time finding any working examples of a php script which calls the API to do these things.… Continue reading
Tagged , , , | Leave a comment

How to calculate the difference between two days as a formatted string?

Here’s what I’ve got so far:
/**
 * Parse a duration between 2 date/times in seconds
 * and to convert that duration into a formatted string
 *
 * @param integer $time_start start time in seconds
 * @param integer $time_end   end
Continue reading
Tagged , , | Leave a comment

Image Gallery System – Which Approach is Better?

I am implementing an image upload system in PHP, The following are required: Have categories Allow users to comment on images Allow rating of images For that, I have 2 approaches in mind: 1. Implement the categorization by folders Each… Continue reading
Tagged , | 3 Comments

Is there a way to set the scope of require_once() explicitly to global?

I’m looking for a way to set the scope of require_once() to the global scope, when require_once() is used inside a function. Something like the following code should work: file `foo.php’:
<?php

$foo = 42;
actual code:
<?php

function
Continue reading
Tagged | Leave a comment
698 pages