首页 > 解决方案 > 如何将数组值附加到字符串?

问题描述

我想将一个数组值附加到字符串的中间。

我尝试将名称设为新变量并附加该变量。我查找了各种方法来仅从数组中获取一个值,但没有什么能满足我的需求。

我有这个数组:

$fields = array(
    'name' => array(
        'rule' => '/.+/',
        'message' => $lang['ADMIN_STORE_NAME_VALIDATE'],
        'value' => '',
        'required' => TRUE
    ),

我想附加商店名称说,这个字符串的结尾

sprintf("A cool new store has been added  please login to administrators area to approve the request")

标签: php

解决方案


.一个连接运算符。因此,请执行以下操作:

$sentence = "A cool new store called " . $fields['name']['message'] . " has been added please login to administrators area to approve the request";

会给你想要的结果。

欲了解更多信息:http ://www.php.net/manual/en/language.operators.string.php


推荐阅读