کمک برای یک تفییر کوچک در اسکریپت randomtext

abbasi_0912

Active Member
با سلام
دوستان من میخواهم کمکم کنید تا یک تغییر در این اسکریپت انجام بدم

PHP:
<?php
//What to Randomize
$randtext[] = "This is some text";
$randtext[] = "<strong>This is some text in bold</strong>";
$randtext[] = "<em>This is some text in italic</em>";

//How to Randomize (leave this part)
srand ((double) microtime() * 1000000);
$randomtext = rand(0,count($randtext)-1);
// How to display it
echo $randtext[$randomtext];
?>

--------------------------------------------------------------

<?php
//برای دیدن نتیجه
echo "<strong>".$randtext[$randomtext]."</strong>"; 
?>


مشکلش اینه که در خروجی به این صورت هست

This is some textThis is some text
یا
This is some text in boldThis is some text in bold
یا
This is some text in italicThis is some text in italic

من میخوام که فقط یکی از اون عبارت ها رو فقط یکبار نشون بده نه دو بار

به عبارتی فقط This is some text رو یک بار نشون بده
اگر تغییر یافته کاملش رو بنویسید ممنون میشم
 

alireza82

Well-Known Member
PHP:
<?php
//What to Randomize
$randtext[] = "This is some text";
$randtext[] = "<strong>This is some text in bold</strong>";
$randtext[] = "<em>This is some text in italic</em>";

//How to Randomize (leave this part)
srand ((double) microtime() * 1000000);
$randomtext = rand(0,count($randtext)-1);
// How to display it

?>

--------------------------------------------------------------

<?php
//برای دیدن نتیجه
echo "<strong>".$randtext[$randomtext]."</strong>"; 
?>
 

abbasi_0912

Active Member
ممنون دوست عزیز
من یه کاری میکردم ولی نتیجه عکس بود
با تغییراتی که شما انجام دادید درست شد .
 

جدیدترین ارسال ها

بالا