dongtui4038
dongtui4038
2018-04-24 10:44
浏览 95
已采纳

在字符串php上插入数组值

I'm getting an error trying to make this

$array = array("text");

echo "text $array['0']";

it's possible to make it shis way instead concatenate

echo "text ".$array['0'];
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongrong5189
    dongrong5189 2018-04-24 10:48
    已采纳

    1. You need to remove ' around 0

    echo "text $array[0]";
    

    Output:- https://eval.in/993458

    2.Or enclose array element with {}

    echo "text {$array['0']}";
    

    Output:-https://eval.in/993460

    点赞 评论
  • dongnunai3125
    dongnunai3125 2018-04-24 10:47

    remove single quotes ' inside double quortes ",

    echo "text $array[0]";
    

    Live Demo

    点赞 评论

相关推荐