Hello,

function dwos($title,$body,$rpcurl,$username,$password,$categories=array(1))
{
$categories = implode(",", $categories);
function here.
}

My question is, how can I put value to categories ?

$category = "life, code, love"; // this not works ?

dwos($title,$body,$rpcurl,$username,$password,$[B]categories=array(1)[/B])

Hello,

function dwos($title,$body,$rpcurl,$username,$password,$categories=array(1))
{
$categories = implode(",", $categories);
function here.
}

My question is, how can I put value to categories ?

$category = "life, code, love"; // this not works ?

dwos($title,$body,$rpcurl,$username,$password,$categories=array(1))

try this

function dwos($title,$body,$rpcurl,$username,$password,$categories)
{
$categories=array();
$categories = implode(",", $categories);
}

try this

function dwos($title,$body,$rpcurl,$username,$password,$categories)
{
$categories=array();
$categories = implode(",", $categories);
}

That will not work. You are initializing an array called categories, then imploding the values in the categories (which will be null, ofcourse) and assign it to a normal variable $categories! :S What will that do ?

@ OP, What are you trying to achieve ?

Your function call itself shouldn't have the =array(1), only the definition should.

Passing an array of values before the function...

$arrCategories = array( 'value 1', 'value 2', 'value 3' );

dwos( $title, $body, $rpcurl, $username, $password, $arrCategories );


function dwos($title,$body,$rpcurl,$username,$password,$categories)
{
[INDENT]$categories = implode(",", $categories);[/INDENT]
}

or adding the values to the already imploded array within the function:

dwos($title,$body,$rpcurl,$username,$password,$categories)
{
[INDENT]$categories = implode(",", $categories);
$categories .= 'these, are, my, new, values';
[/INDENT]
}

Hope this helps.

R

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.