This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fh = fopen("contacts.csv", "r"); | |
while($line = fgetcsv($fh, 1000, ",")) { | |
echo "Contact: {$line[1]}"; | |
} | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function extract_emails($str){ | |
$regexp = '/([a-z0-9_\.\-])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; | |
preg_match_all($regexp, $str, $m); | |
return isset($m[0]) ? $m[0] : array(); | |
} | |
$test_string = 'This is a test string... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$from = new DateTime('0000-00-00 00:00:00'); | |
$to = new DateTime('now'); | |
$interval = $to->diff($from); | |
//2011 years, 4 months, 5 days, 11 hours, 13 minutes, 49 seconds | |
echo $interval->format('%Y years, %m months, %d days, %H hours, %i minutes, %s seconds'); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*********************************************************************************************************************\ | |
* LAST UPDATE | |
* ============ | |
* March 22, 2007 | |
* | |
* | |
* AUTHOR | |
* ============= | |
* Kwaku Otchere |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function contains($str, $content, $ignorecase=true){ | |
if ($ignorecase){ | |
$str = strtolower($str); | |
$content = strtolower($content); | |
} | |
return strpos($content,$str) ? true : false; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Open file | |
$handler = fopen ("file.txt", "r"); | |
//Read file, line to line | |
while (!feof ($handler)) { | |
//Read one line | |
$line = fgets($handler, 4096); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//in theme function.php | |
//get post images | |
function post_get_images($ind=NULL){ | |
global $post; | |
$url_alternative = 'http://www.google.com.br/intl/en_com/images/srpr/logo1w.png'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $popular = new WP_Query('orderby=comment_count&posts_per_page=5'); ?> | |
<?php while ($popular->have_posts()) : $popular->the_post(); ?> | |
<?php | |
$justanimage = get_post_meta($post->ID, 'Image', true); | |
if ($justanimage) { | |
?> | |
<img src="<?php echo get_post_meta($post->ID, "Image", true); ?>" alt="<?php the_title(); ?>" /> | |
<?php } else { ?> | |
<img src="http://an-alternative-image.jpg" alt="" /> | |
<?php } ?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php wp_enqueue_script("jquery"); ?> |