I’m trying to get this random array to work properly. Someone else helped me with the code and I can’t find the problem in it. It’s part of a wordpress plugin that remotely posts to other sites. I was attempting to add keywords to the title and permalink but for some reason it’s adding all of the keywords instead of grabbing one.
Here’s a partial section of the code:
[php]function syn_syndicate_box() {
global $syn_multi_curl;
$syn_multi_curl = new MultiCurl();
$options = syn_get_admin_options();
$keywords1 = array("Keyword", "Keyword", "Keyword", "Keyword", "Keyword", "Keyword", "Keyword");
$keywords2 = array("Keyword", "Keyword", "Keyword", "Keyword", "Keyword", "Keyword", "Keyword");
$post = wp_get_single_post( $_GET[ 'post_id' ] );
$title = $post->post_title;
$permalink = get_permalink( $post->ID );
$content = $post->post_content;
$content = strip_tags( $content );
$content = substr( $content, 0, $options[ 'excerpt_length' ] );
$needle = chr( 194 ) . chr( 160 );
$content = str_replace( $needle, ' ', $content );
$options[ 'bitly_url' ] = syn_shorten_url( $options, $permalink );
$sites = syn_get_sites();
foreach ( $sites as $site ) {
$randomNumber1 = rand(0, count(keywords1)-1);
$randomNumber2 = rand(0, count(keywords2)-1);
$keyword1 = $keywords1[$randomNumber1];
$keyword2 = $keywords2[$randomNumber2];
$title = $keyword1 ." " . $title . " " . $keyword2;
$site = str_replace( ' ', '_', strtolower( $site ) );
if ( isSet( $_POST[ $site . '_enabled' ] ) ) {
try {
call_user_func_array( 'syn_post_' . $site, array(
$options, $title, $content.'<p><strong><a href="' . $permalink . '">' . $title . '</a></strong></p>'
));[/php]
Any ideas on what the problem is?