Fungsi spin text php

<?php
function spinText($text){ 
    $test = preg_match_all("#\{(.*?)\}#", $text, $out); 
    if (!$test) return $text; 
    $toFind = Array(); 
    $toReplace = Array(); 
    foreach($out[0] AS $id =&gt; $match){ 
    $choices = explode("|", $out[1][$id]); 
    $toFind[]=$match; 
    $toReplace[]=trim($choices[rand(0, count($choices)-1)]); 
    } 
    return str_replace($toFind, $toReplace, $text); 
} 

?>

Posting Komentar

Lebih baru Lebih lama