开发者

Set variable to array element

I need to set a variable = to an array element. $var = $ary[1]; does not work. ary[1]= "test". If that 开发者_开发问答helps


PHP arrays are zero indexed, that may be your problem

    $ary = array("test");
    $var = $ary[0]

$var == "test"


confirm that your first initialize the array variable before using it like:

$ary=array();

Try this:

$ary[]= $var;

must use $ sign for var/arrays in php and you don't require 1 if a single value is inserted..


This is the way to set a variable with array elemen.

why it is not working , please check your array content .

http://php.net/manual/en/language.types.array.php


Try using

$content = array( "en" => "{$massage}" );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜