我创建了一个文本和链接数组,并随机选择一个以显示在我的网站上的新闻栏中

I create an array of text and links and randomly pick one to get displayed in a news bar on my website here I want this script to be optimized as well as having an extra 'feature' I want to be able to determine the amount of times it appears for Ex:: "good morning" to be displayed 10% of the time.

<?php

    $news = array(); //News Feed Array
    $news[] = '<a href="URL">Good morning!</a>';
    $news[] = '<a href="URL">have a nice day</a>';
    $news[] = 'work hard!';
    $news[] = '<a href="URL">experience makes man perfect.</a>';
    $news[] = '<a href="URL">hard work never fails</a>';

    echo $news[array_rand($news)];
?>

May be this link will be useful but cant say upto what extent for your specific purpose but is worth checking.

You may also refer this answer.