Latest
Perform a function on an array of items (105)
Date Published: November 07, 2009
 <?php 
$old 
= array('Block''inline');
$new array_map('strtoupper'$old);

 
// $new is now array('BLOCK', 'INLINE');
?>
         
››Link
Create Post Slugs (120)
Date Published: November 07, 2009
 <?php 
function create_slug($string){  
    
$slug=preg_replace('/[^A-Za-z0-9-]+/''-'$string);  
    return 
$slug;  
}
?>
         
››Link
Parse JSON Data (135)
Date Published: November 07, 2009
 <?php 
$json 
='{"id":1,"name":"foo","interest":["wordpress","php"]} ';  
$obj=json_decode($json); 
echo 
$obj->interest[1]; //prints php
?>
         
››Link
Returns the current URL address minus the domain name (121)
Date Published: October 20, 2009
 <?php 
$pageOn 
basename($_SERVER['REQUEST_URI']);
echo 
$pageOn//returns the current URL address
 
minus the domain name
?>
         
››Link
Random number (86)
Date Published: October 20, 2009
 <?php 
          
  
echo mt_rand(110000) . "<br />"
  echo 
mt_rand(110000) . "<br />"


?>  
››Link
Retrieve server datetime formatted (123)
Date Published: October 20, 2009
 <?php 
//formats current date and time to datetime 
format 
$myServerDatetime 
date("Y-m-d G:i:s"); 

echo 
$myServerDatetime;

?> 
››Link
Simple Array (111)
Date Published: October 20, 2009
 <?php
$x
=array(1=>"one","two","three");
foreach (
$x as $key => $val)
  {
  echo 
$key "=>" $val "<br />";
  }
?> 
››Link
Date Calculations using Unix Timestamps (116)
Date Published: October 20, 2009
 <?php
$tomorrow 
mktime(000date("m"), 
date("d")+1date("y"));
echo 
"Tomorrow is ".date("m/d/y"$tomorrow); 
?> 
››Link
Fast Letter Wheel (89)
Date Published: October 20, 2009
 <?php
foreach (range('a''z') as $char) {
  print 
'<a href="#' $char '">' 
  
$char '</a> | ';
}
?> 
››Link
Produce random string using different character types (124)
Date Published: October 20, 2009
 <?php
$string 
"abcdwxyz456789";  
for(
$i=0;$i<25;$i++){  
    
$pos rand(0,13);  
    
$str .= $string{$pos};  
}  
echo 
$str;

?> 
››Link