I want to validate a registration form that accepts an email address in the following format (it's a subdomain)P
[email protected]
Actually,because there can be so many variations of emails nowadays, is there a handy regex for checking just the last part of the email e.g. .ie, or .com
GF
...
Im used to working with twitter, where friend/follower totals are available in a simple xml request.
My goal is a simple "enter your username/user id, and display your friends count".
Is there something like this for facebook? From what i gather, ill have to make an application, and have anyone who wants to grab their friends total act...
Hi,
I have in one project classes organized with ActivePattern (example : myObject->Load()) but now we need to implement some caching and caching is problematic.
To make it simples, the Load() method in every object call the DAL my giving the $this reference and the DAL fill up the object that all values. It works. But when we add some...
I'm trying this code (on my local web server)
<?php
echo 'the word is / думата е '.$_GET['word'];
?>
but I get corrupted result when enter ?word=проба
the word is / думата е ����
The document is saved as 'UTF-8 without BOM' and headers are also UTF-8.
I have tried urlencode() and urldecode() but the effect was same.
When upload it ...
Hi folks!
I'm writing a factory class that should be able to return singleton instances of a number of different types, depending on the given parameter. The method would look something like this, but the way I'm referencing the singleton's static method is obviously wrong:
public function getService($singletonClassName) {
return $...
Any idea why this wont print the errors?
// Validate the email
if (preg_match($regex, $email))
$errors[] = "Invalid email address";
// ... and the password
if (strlen($password) < 4)
$errors[] = "Password is too short";
// No errors?
if (empty($errors))
{
// insert into db
}
// If...
I'm wondering if anyone knows of a PHP library that I could compile into my app for the iPhone? Basically I'm wanting to allow the phone to display pages stored locally that have PHP in them and display them in a UIWebView.
...
I'd like to convert a normal link tag into an image tag,
How would I convert this following,
<a href="images/first.jpg">This is an image.</a>
<a href="images/second.jpg">This is yet another image.</a>
<a href="images/third.jpg">Another image.</a>
Into this with php,
<img src="dir/images/first.jpg">This is an image.
<img src="dir...
i have this function to return the full directory tree:
function getDirectory( $path = '.', $level = 0 ){
$ignore = array( 'cgi-bin', '.', '..' );
// Directories to ignore when listing output. Many hosts
// will deny PHP access to the cgi-bin.
$dh = @opendir( $path );
// Open the directory to the handle $dh
while( false !== ( $file =...
Im trying to grab the destination (dynamic) of a link (static) with php
Im not sure what the best way to do this is.
the link is
<a href=page.php?XXYYYYYYY>LinkName</a>
the X's are letters and the Y's are numbers (both can vary in length). 'Linkname' always stays the same though.
Is regex the best option here? Or is there a better ...
Sorry for the poor title, but as im not a experinced programmer i could think of a better one
Instead of storing errors in arrays, then show a list of errors in some of my forms i would like to show them next to the input field. Its so sexy!
How would you suggest I do this?
Set a variable like, $wrongemail = 1;, $tooshortpass = 1; if ...
Would somebody care to help me out with a regex to reliably recognize and remove any number, followed by a dot, in the beginning of a string? So that
1. Introduction
becomes
Introduction
and
1290394958595. Appendix A
becomes
Appendix A
...
I'm new to PHP and I want this code <option value="" disabled="disabled">-------------</option> to be disabled when the php code is building my select list of options. How can I fix my php code so it will always set that specific option to disabled?
Here is part of the php code.
echo '<select name="country" id="country" size="20">' . ...
Here is what I'm trying to do:
- i need a function that when passed as an argument an ID (for a category of things) will provide all the subcategories and the sub-sub categories and sub-sub-sub..etc.
- i was thinking to use a recursive function since i don't know the number of subcategories their sub-subcategories and so on
so here is w...
How could I extend objects provided with Document Object Model? Seems that there is no way according to this issue.
class Application_Model_XmlSchema extends DOMElement
{
const ELEMENT_NAME = 'schema';
/**
* @var DOMElement
*/
private $_schema;
/**
* @param DOMDocument $document
* @return void
...
Since PHP has no custom-class type-casting, how would I go about doing the PHP equivalent of this Java code:
CustomBaseObject cusBaseObject = cusBaseObjectDao.readCustomBaseObjectById(id);
((CustomChildObject) cusBaseObject).setChildAttribute1(value1);
((CustomChildObject) cusBaseObject).setChildAttribute2(value2);
In my case, it woul...
Hi all,
I'm using the function preg_replace but I cannot figure out how to make it work, the function just doesn't seem to work for me.
What I'm trying to do is to convert a string into a link if any word contains the % (percentage) character.
For instance if I have the string "go to %mysite", I'd like to convert the mysite word into a...
I have this code here:
NSString *post = [NSString stringWithFormat:@"deviceIdentifier=%@&deviceToken=%@",deviceIdentifier,deviceToken];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:NO];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [...
Hi,
I built a class that allows me to do:
$db->query($query);
and it works perfectly, although if I want to do:
$db->query($query);
while($row = $db->fetch_assoc()){
$db->query($anotherquery);
echo $db->result();
}
it "breaks" the class. I don't want to constantly have to redeclare my class (eg: $seconddb = new database()...
I have a list of files in an array where the filename is the key and the value is the last modified date in seconds. They are sorted from oldest to newest.
The files are glob()'d in, and then sorted this way using
asort($fileNameToLastModified, SORT_NUMERIC);
I use array_shift() to get the oldest file. Unfortunately, it seems to be ...