首页 > 解决方案 > 数组中的数据不一样

问题描述

我有一个我创建的数组。当用它读取数组时print_r,没有返回输入正确的数据!我缺少特定的部分,例如< & >带有标题的括号。

我怎样才能保存这些?

代码:

$params = array(
    "Parm1" => "test",
    "Parm2" => "hi",
    "Parm3" => GUID(),
    "Parm4" => "lol",
    "Parm5" => "
    <R>
      <R1>the</R1>
      <R2>dog</R2>
      <R3>is</R3>

      <R15>happy</R15>

      <R20>today</R20>
    </R>
");

基本上,唯一混乱的数据是该Parm5部分。我希望里面的所有东西都能原样返回!EG:按原样阅读我只收到Array ( [Parm1] => test [Parm2] => hi [Parm3] => B18BE727-8F79-4D4A-80EA-3974B1429F78 [Parm4] => lol [Parm5] => the dog is happy today )来自print_r

我想返回:

Array ( [Parm1] => test [Parm2] => hi [Parm3] => B18BE727-8F79-4D4A-80EA-3974B1429F78 [Parm4] => lol [Parm5] => <R><R1>the</R1> <R2>dog</R2> <R3>is</R3> <R15>happy</R15> <R20>today</R20></R> )

标签: phparrays

解决方案


htmlspecialchars在 的返回值上使用print_r

echo "<pre>";    
echo htmlspecialchars(print_r($params, true));
echo "</pre>"; 

推荐阅读