【问题标题】:How to put a text and a string inside array如何将文本和字符串放入数组中
【发布时间】:2017-12-05 10:35:08
【问题描述】:

我已经创建了这段代码

 $S_Jenis = $_POST['JenisTrx'];
 $S_Keterangan = $_POST['KeteranganTrx'];
 $S_Jumlah = $_POST['JumlahTrx'];

我在这里称呼它

$msg = array
      (
    'body'  => $S_Keterangan Rp$S_Jumlah,
    'title' => Kas $S_Jenis,
            'icon'  => 'myicon',
            'sound' => 'mySound'
      );

但是如果我将“Kas”放在标题中,将 2 个字符串放在正文中,这是一个错误,有人知道如何解决这个问题吗?

【问题讨论】:

  • 'title' => 'Kas' . $S_Jenis。与上一行相同,PHP 基本和字符串连接。
  • Kas 应该怎么做?

标签: php arrays string text


【解决方案1】:

试试下面的代码

$msg = array
      (
    'body'  => $S_Keterangan ."Rp".$S_Jumlah,
    'title' => "Kas".$S_Jenis,
            'icon'  => 'myicon',
            'sound' => 'mySound'
      );

【讨论】:

    【解决方案2】:

    假设你想连接这些字符串:

    $msg = array(
      'body'  => $S_Keterangan . ' Rp' . $S_Jumlah,
      'title' => 'Kas' . $S_Jenis,
      'icon'  => 'myicon',
      'sound' => 'mySound'
    );
    

    要了解 PHP 中的字符串连接,请参阅:http://php.net/manual/en/language.operators.string.php

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-25
      • 2011-07-23
      • 1970-01-01
      相关资源
      最近更新 更多