Example #1
0
File: seo.php Project: anvogel/Repo
    //convert the spaces to whatever the user wants
    //usually a dash or underscore..
    //...then return the value.
    return str_replace(' ', $replace, $return);
}
/* takes an input, scrubs unnecessary words */
function remove_words($input, $replace, $words_array = array(), $unique_words = true)
{
    //separate all words based on spaces
    $input_array = explode(' ', $input);
    //create the return array
    $return = array();
    //loops through words, remove bad words, keep good ones
    foreach ($input_array as $word) {
        //if it's a word we should add...
        if (!in_array($word, $words_array) && ($unique_words ? !in_array($word, $return) : true)) {
            $return[] = $word;
        }
    }
    //return good words separated by dashes
    return implode($replace, $return);
}
$bad_words = array('a', 'and', 'the', 'an', 'it', 'is', 'with', 'can', 'of', 'why', 'not');
echo generate_seo_link('Another day and a half of PHP meetings änder über', '-', true, $bad_words);
//displays :: another-day-half-php-meetings
echo "<br>";
echo generate_seo_link('CSS again?  Why not just PHP?', '-', true, $bad_words);
//displays :: css-again-just-php
echo "<br>";
echo generate_seo_link('A penny saved is a penny earned.', '-', true, $bad_words);
//displays :: penny-saved-earned
Example #2
0
 unset($rows);
 # Entradas
 $entrada = new ab_entryTable();
 $entrada->readEnv();
 #$entrada->limit = ENTRY;
 #$entrada->offset = (($pg>1)?(($pg-1)*$entrada->limit):0);
 if ($_REQUEST['m']) {
     $period = strftime("%B/%Y", strtotime($_REQUEST['y'] . '-' . $_REQUEST['m'] . '-01'));
     $range_filter = "extract(month from ab_entry.creation) = " . $_REQUEST['m'] . " AND extract(year from ab_entry.creation) = " . $_REQUEST['y'];
 } else {
     $period = $_REQUEST['y'];
     $range_filter = "extract(year from ab_entry.creation) = " . $_REQUEST['y'];
 }
 $rows = $entrada->readDataFilter("ab_entry.public IS TRUE AND {$range_filter}");
 for ($i = 0; $i < count($rows); $i++) {
     $rows[$i]['seo_title'] = generate_seo_link($rows[$i]['ab_entry']);
     $rows[$i]['texto'] = strip_code($rows[$i]['texto']);
 }
 $smarty->assign('entradas', $rows);
 $smarty->assign('title', $period . ' &#8212; Archivo');
 $smarty->assign('period', $period);
 unset($rows);
 $smarty->assign('pgs', $pgs);
 $smarty->assign('pg', $pg);
 unset($rows);
 # Ultimas Entradas
 $entrada->readEnv();
 $entrada->limit = 10;
 $rows = $entrada->readDataFilter("public IS TRUE");
 $smarty->assign('ult_entradas', $rows);
 unset($rows);