Jump to content

concatenate with $var


Frame

Recommended Posts

<?php

$input = array("Prefix 1", "Prefix 2", "Prefix 3", "Prefix 4", "Prefix 5");
$rand_keys = array_rand($input, 2);
$var = $input[$rand_keys[1]];

function tweet($username, $password, $message){

    $api_url = 'http://twitter.com/statuses/update.xml';

$body =    array( 'status'=>echo $var . $message );
$headers = array( 'Authorization' => 'Basic '.base64_encode("$username:$password") );

$result = fetch_url( $api_url, 'POST', $body, $headers );

return ( preg_match_all('!<error>[^<]+</error>!', $result, $matches) !== 1 );
}

 

returns: Parse error: syntax error, unexpected T_ECHO in ...

 

I have success with ( 'status'=>'Prefix' . $message ) were the Prefix and message are posted. Also just $var succeeds in sending message, but without the prefix. Any other syntax combo ends in an error. I don't know how to code this correctly. Any help is appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/206434-concatenate-with-var/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.