PHP - RSS/Atom feed parser - DOM
A way to parse RSS or ATOM feeds using “Document Object Model” and output it into array:
<?php
function rss_to_array($tags, $array, $url) {
/*RSS and ATOM*/
$doc = new DOMdocument();
@$doc->load($url);
$rss_array = array();
foreach($tags as $tag) {
if ($doc->getElementsByTagName($tag)) {
foreach($doc->getElementsByTagName($tag) AS $node) {
$items = array();
foreach($array AS $key => $values) {
$items[$key] = array();
foreach($values as $value) {
if ($itemsCheck = $node->getElementsByTagName($value)) {
for( $j=0 ; $j < $itemsCheck->length; $j++ ) {
if (($attribute = $itemsCheck->item($j)->nodeValue) != “”) {
$items[$key][] = $attribute;
} else if ($attribute = $itemsCheck->item($j)->getAttribute(’term’)) {
$items[$key][] = $attribute;
} else if ($itemsCheck->item($j)->getAttribute(’rel’) == ‘alternate’) {
$items[$key][] = $itemsCheck->item($j)->getAttribute(’href’);
}
}
}
}
}
array_push($rss_array, $items);
}
}
}
return $rss_array;
}
$rss_item_tags = array(’item’, ‘entry’);
$rss_tags = array(
‘title’ => array(’title’),
‘description’ => array(’description’, ‘content’, ’summary’),
‘link’ => array(’link’, ‘feedburner’),
‘category’ => array(’category’)
);
$rssfeed = rss_to_array($rss_item_tags, $rss_tags, $url);
echo ‘<pre>’;
print_r($rssfeed);
echo ‘</pre>’;
exit;
?>
PHP - Get url variables case insensitive
$str = $_SERVER[’QUERY_STRING’];
parse_str($str, $output);
foreach($output as $key => $value) {
$QUERY[strtolower($key)] = $value;
}
print_r($QUERY);
Example: url:
http://www.site.com/index.php?ID=C22&Var2=DA&vAr3=DA&LINK=Test
Array
(
[id] => C22
[var2] => DA
[var3] => DA
[link] => Test
)
Teen Dating Quiz
All The Single Lady Lyric
Meet Fuck Therapy Game
Dating Personal Free With Photo
Meet The Robinsons Walk Through
Meet Fuck Game
Russian Bride For Sale
Dating Internet Online Personal
The Sims 2 Single Mom
Mother Of The Bride Formal Wear
Generate a unique ID 10 characters long - PHP
A PHP function to generate a unique ID 10 characters long based on the current UNIX timestamp (10 digits).
<?php
function gen_uniqid() {
$char[0] = "ABCDEFGHIJ";
$char[1] = "KLMNPQRSTU";
$char[2] = "VWXYZabcde";
$char[3] = "fghijklmnp";
$char[4] = "qrstuvwxyz";
$char[5] = "0123456789";
$arr = preg_split('//', time(), -1, PREG_SPLIT_NO_EMPTY);
$uniqid = "";
foreach($arr as $val) {
$str = $char[rand(0,5)];
$uniqid .= $str{$val};
}
return $uniqid;
}
echo gen_uniqid();
?>
