开发者

Set variable to array element

开发者 https://www.devze.com 2023-03-09 08:50 出处:网络
I need to set a variable = to an array element. $var = $ary[1]; does not work. ary[1]= \"test\". If that 开发者_开发问答helpsPHP arrays are zero indexed, that may be your problem

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

精彩评论

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