php - 如何将数组值附加到字符串?
问题描述
我想将一个数组值附加到字符串的中间。
我尝试将名称设为新变量并附加该变量。我查找了各种方法来仅从数组中获取一个值,但没有什么能满足我的需求。
我有这个数组:
$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")
解决方案
是.
一个连接运算符。因此,请执行以下操作:
$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
推荐阅读
- batch-file - 从批处理文件运行后如何自动关闭tinyweb控制台
- java - PriorityQueue 的比较如何工作
- nlp - 使用 word2vev 的句子相似度
- neo4j - 如何在 cypher neo4j 中正确执行 OR 条件
- python - 如何在不是条形值的条形顶部添加唯一值?
- session - 多域会话 cookie
- node.js - 使用请求 PATCH 从 ElectronJS 更新 Discord Profile 图片
- azure - 使用 RM 模块的 Azure 存储帐户密钥更新
- excel - Excel:基于文本和日期的 SUMIFS 方程
- sql - 如何对在交易级别存储的定价数据(或取消存储数据)运行汇总统计?