Hello Guys, I need a little help with the below example, can someone simplify this for me? define("PRT11_WIDTH", 600); define("PRT11_HEIGHT", 365); define("PRT11_REGEXP", "/\[v1-1]/"); define("PRT11_TARGET", "<div class=\"nanotabs\"><div id=\"ichi($string)\">"); function PRT11_plugin_callback($match) { $output = PRT11_TARGET; $output = str_replace("###URL###", $match[1], $output); return ($output); } function genRandomString() { $length = 5; $characters = ’0123456789abcdefghijklmnopqrstuvwxyz’; $string = â€; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } function PRT11_plugin($content) { return preg_replace_callback(PRT11_REGEXP, 'PRT11_plugin_callback', $content); } add_filter('the_content', 'PRT11_plugin'); add_filter('the_content_rss', 'PRT11_plugin'); add_filter('comment_text', 'PRT11_plugin'); add_filter('the_excerpt', 'PRT11_plugin'); PHP: Basically this is a shortcode, [v1-1] will output <div class="nanotabs"><div id="ichi(RANDOM#Here)"> HTML: I need a random # generated after id="ichi(HERE)" However I can't get it to work...Can someone help me here? Can This entire code be simplified?
define("PRT11_WIDTH", 600); define("PRT11_HEIGHT", 365); define("PRT11_REGEXP", "/\[v1-1]/"); define("PRT11_TARGET", "<div class=\"nanotabs\"><div id=\"ichi'.time().'\">"); function PRT11_plugin_callback($match) { $output = PRT11_TARGET; $output = str_replace("###URL###", $match[1], $output); return ($output); } function genRandomString() { $length = 5; $characters = ’0123456789abcdefghijklmnopqrstuvwxyz’; $string = â€; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } function PRT11_plugin($content) { return preg_replace_callback(PRT11_REGEXP, 'PRT11_plugin_callback', $content); } add_filter('the_content', 'PRT11_plugin'); add_filter('the_content_rss', 'PRT11_plugin'); add_filter('comment_text', 'PRT11_plugin'); add_filter('the_excerpt', 'PRT11_plugin'); Code (markup):
This is what outputed : <div class="nanotabs"><div id="ichi'.time().'"> HTML: ??? I dont understand where you got the '.time().' ???
time is a unix timestamp. you can create random numbers this way. I left out the double quotes define("PRT11_TARGET", "<div class=\"nanotabs\"><div id=\"ichi".time()."\">"); Code (markup):