Recent Notes
Displaying keyword search results 91 - 100
Created by jinx on April 10, 2011 14:14:29
Last update: April 10, 2011 14:14:46
The count function can be used to get the length of a PHP array. In PHP, there's no difference between an array with integer indexes and a map with string keys. Strings and integers are used interchangeably, '100' and 100 are the same when used as keys to an (associative) array.
sizeof is an alias of count .
<?php
$a[100] = '100';
echo "Length of \$a: ...
Outputs:
Length of $a: 1
Length of $a: 2
Length of $a...
Created by jinx on April 05, 2011 12:10:54
Last update: April 05, 2011 12:12:31
The filter_var function can be used to validate an email address:
<?php
var_dump(filter_var('bob@example.com', FI...
Created by jinx on April 05, 2011 12:06:06
Last update: April 05, 2011 12:08:12
This is from Stackoverflow . It takes care of various possible headers set by proxies. Pretty neat!
<?php
function get_ip_address()
{
for...
Created by jinx on April 05, 2011 11:42:51
Last update: April 05, 2011 11:42:51
Use the ip2long function to check IP address range in PHP. The following code checks to see if an IP address falls in the private network ranges:
#!/usr/bin/php
<?php
function is_private_ip(...
Created by jinx on April 05, 2011 08:59:29
Last update: April 05, 2011 08:59:29
<?php
$useragent = $_SERVER ['HTTP_USER_AGE...
PHP also provides get_browser function, which returns an object or array. But that requires browscap configuration which locates the browscap.ini file.
Created by James on April 04, 2011 19:41:51
Last update: April 04, 2011 19:41:51
Use the nodeName attribute to get the name of the HTML tag, tagName is not recommended .
<!DOCTYPE html>
<html>
<head>
<title>jQu...
Created by Dr. Xi on December 24, 2009 22:25:38
Last update: April 04, 2011 13:48:24
Use the urlparse module to parse a URL into parts.
The urlparse function parses a URL into six components, returning a 6-tuple. This corresponds to the general structure of a URL: scheme://netloc/path;parameters?query#fragment
>>> from urlparse import urlparse
>>> parts = u...
Created by James on March 29, 2011 11:37:53
Last update: March 29, 2011 11:37:53
The test page below reports the column and row indexes of the table cell you clicked.
<!DOCTYPE html>
<html>
<head>
<title>jQu...
Created by James on March 29, 2011 11:34:53
Last update: March 29, 2011 11:34:53
The width() function returns the width of an element. The test page below shows how to retrieve widths for table cells. The row parameter can be omitted if columns in all rows are of same width.
<!DOCTYPE html>
<html>
<head>
<title>jQu...
Created by James on March 29, 2011 11:28:33
Last update: March 29, 2011 11:30:12
The test page below shows how to count the number of columns for a given table row with jQuery:
$('table tr:eq('+row+') td').length
<!DOCTYPE html>
<html>
<head>
<title>jQu...