php

Validating a date dd/mm/yyyy

Hi, Does anyone know of any good functions for validating a date via input text box in codeigniter like this: dd/mm/yyyy? Thanks ...

Regex / DOMDocument - match and replace text not in a link

I need to find and replace text in a case insensitive way, unless it is within an anchor tag - for example: <p>Match this text and replace it</p> <p>Don't <a href="/">match this text</a></p> Searching for 'match this text' would only replace the first instance. [Edit] As per Gordon's comment, it may be preferred to use DOMDocument in...

Shortening an array based on consecutive occurences.

I'm in the middle of learning PHP, and the following list-related problem has come up. The language doesn't really matter, so I'll give you this in pseudo-code. Pseudo-code answers are fine, of course. Say, there's a list of two different, repeating elements - two single characters, for instance. So my list looks roughly like this: myL...

How can I use PHP to list all the dates in a year?

Hi, I'm trying to use PHP to create a script that searches all the days between now and one year's time and lists all the dates for Fridays and Saturdays. I was trying to use PHP's date() and mktime() functions but can't think of a way of doing this. Is it possible? Thanks, Ben ...

How can I find the most frequently recurring item in an array?

What would be the best approach to create the function getMostFrequentlyOccurringItem() below? //should return "paragraph" echo getMostFrequentlyOccurringItem(array('line', 'paragraph', 'paragraph')); //should return "line" echo getMostFrequentlyOccurringItem(array('wholeNumber', 'line', 'line', 'line')); //should return null echo get...

how to collect contacts from different accounts

hi so i was wondering this: for example: when you subscribe to Facebook you have the option to invite your friends from gmail(if you have a gmail account), so you would enter your gmail login and password and facebook would grab all your contacts from gmail, so i was wondering how this is done? is there an API from Gmail or from Hotmail...

Date not showing on consecutive posts on Wordpress

Hi everyone, I have a news section that shows posts only with a category of "news". The code is shown below. The problem is, only the first news post gets a date above it. All the posts following the most recent "news post" don't have dates. Anyone have any idea why this is happening? Thanks! Amit <div id="news"> <?php ...

PHP: PEAR mail help

I'm trying out the mail pear package. It successfully sends an email but give me the following error: Strict Standards: Non-static method Mail::factory() should not be called statically, assuming $this from incompatible context in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\ClientPortal\classes\SupportTickets.php ...

Sprite Sheets for Web Development

I'm currently working on a new site. I'm just a few pages deep and they all use <img>s. I was thinking about it and decided to look into using a sprite sheet for all of the button images and such and then just using CSS to render the appropriate images. I wanted to see what everyone thought about this. Is it worth the effort? How does it...

Get data from specific HTML table cells using Php

I need to get the data out of all of the table cells in the 4th row of the 4th table on an HTML page. After researching for a while, it seems that using DOMXPath is the best way to parse the HTML file. However, no IDs or classes are used anywhere in the file. What would be the best way to get the data out of these cells? Thanks in advan...

Convert date in php

How to convert "Thu Oct 28 16:33:29 +0000 2010 " to like "Oct 28,2010 at 10:33PM" ...

Grab the video ID only from youtube's URLs

How can I grab the video ID only from the youtube's URLs? For instance, http://www.youtube.com/watch?v=aPm3QVKlBJg sometime the URLs contain other information after the 'v' like http://www.youtube.com/watch?v=Z29MkJdMKqs&amp;feature=grec_index but I don't want the other info, just video ID. I only can think of using explod...

WP_Query + $query_vars + custom field

I have custom post type items in my theme. They represent projects in portfolio. I have a custom field checkbox that sets the option "Featured" for every single project. So, when the project is featured, it's being shown on the main page of the site. If the "Featured" checkbox is unset, the project is visible only on the portfolio page. ...

Find the count of EMPTY or NULL columns in a MySQL table

I have around 30 columns in a MySQL table. I want to calculate how many column fields for a particular row are empty. This table is for storing user information. I want to find out how many profile fields (such as 'Name', 'Age', 'Location' - all of which are stored in a separate column) are empty/haven't been filled in by the user. Th...

session_set_save_handler - Why isn't this code working?

Hello, I've been trying to save PHP session data in a MySQL database, but can't get it to work. For a simple example, here's code that should increment a counter with each visit. I've seen other examples, etc. but can someone please tell me why this code isn't working? (Apache/2.2.11 (Win32) DAV/2 mod_ssl/2.2.11 OpenSSL/0.9.8i PHP/5....

Accessing a database from CakePHP when behind a proxy server

I'm working on a web application that's using CakePHP and MySQL. Depending on the circumstances, I may be using one of two computers and I may be behind a proxy server that won't allow me to directly modify any code on my web server. Because of this, I've installed XAMPP on my machines to act as a local web server, and I keep my code i...

Nusoap simpletype enumeration

I have a enumeration class and I want to set valuse from this in a function. But I`m not abel to do this. It allways picks the fist in line, her it is Customer. $server->wsdl->addSimpleType( 'AddressType', 'xsd:string', 'SimpleType', 'struct', array( 'Customer', 'Order', 'Delivery', 'In...

Regex match that must contain all characters in a string

I'm sure this has already been asked and answered, but I honestly couldn't find my answer after searching for quite a bit and reading Regex Tutorial. What I'm looking to do is match a string that has the same characters and length as another string. For example, a string "abcde" would match "edcba" but would not match "abcdf" or "aabbc...

[PHP CURL] Is it possible do only download a portion of a binary file

Hi! A small question concerning downloading xml files from a remote server. I am using curl to achieve this. The information I need in those xml files are located in the first couple of lines of code. Now my question is : Is it possible to download only a portion ( or a defined amount of bytes ) from these xml files , so I only have t...

Getting warning on ftp_get() in PHP

I try to retrieve a text file using ftp_get() and when I execute the script I get warning: ftp_get() [function.ftp-get]: Can't open data connection Can some one give some clue what is wrong. This was working on my previous hosting/server since I moved it it broke. Are there some specific PHP configurations. I checked the phpinfo and ...