数组 html text,注意:数组转换为字符串$ text = $ htmlTag [0] [重复](Notice: Array to string conversion $text = $html...

注意:数组转换为字符串$ text = $ htmlTag [0] [重复](Notice: Array to string conversion $text = $htmlTag[0] [duplicate])

我收到了通知:

注意:第148行的E:\ XAMP \ htdocs \ 1 \ plugins \ content \ cedtag \ cedtag.php中的数组到字符串转换注意:E:\ XAMP \ htdocs \ 1 \ plugins \ content \ cedtag \中的数组到字符串转换第141行的cedtag.php

这是我收到错误的代码的一部分:

if ($position == 1) {

$text = $htmlTag[0] . $text;

} else {

if ($position == 2) {

// Both before and after Text

$text = $htmlTag[0] . $text . $htmlTag[0];

} else {

// After Text

$text .= $htmlTag[0];

}

}

我该如何解决?

This question already has an answer here:

I am getting the notice:

Notice: Array to string conversion in E:\XAMP\htdocs\1\plugins\content\cedtag\cedtag.php on line 148 Notice: Array to string conversion in E:\XAMP\htdocs\1\plugins\content\cedtag\cedtag.php on line 141

This is the part of the code where I'm getting the error:

if ($position == 1) {

$text = $htmlTag[0] . $text;

} else {

if ($position == 2) {

// Both before and after Text

$text = $htmlTag[0] . $text . $htmlTag[0];

} else {

// After Text

$text .= $htmlTag[0];

}

}

How can I resolve it?

原文:https://stackoverflow.com/questions/32472760

更新时间:2019-06-18 20:28

最满意答案

在变量上尝试print_r()或var_dump() 。 其中一个是Array,PHP无法将Array转换为字符串。

Try print_r() or var_dump() on your variables. One of them is an Array and PHP can't convert an Array into a string.

相关问答

听起来你想要显示每个字节的数值,可能由某种字符分隔: string.Join("separator", bytes)

如果要在基础中显示,可以使用LINQ: bytes.Select(b => Convert.ToString(b, 2))

It sounds like you want to display the numeric value of each byte, presumably separated by some kind of character: string.Join("

...

在变量上尝试print_r()或var_dump() 。 其中一个是Array,PHP无法将Array转换为字符串。 Try print_r() or var_dump() on your variables. One of them is an Array and PHP can't convert an Array into a string.

即使我设置了获取模式: $SQL->setFetchMode(PDO::FETCH_ASSOC);

它仍然不会在while循环中使用关联数组,所以我不得不像这样更改语句: while($row = $SQL->fetch(PDO::FETCH_ASSOC)) {}

Even though I set the fetch mode: $SQL->setFetchMode(PDO::FETCH_ASSOC);

It still wouldnt use an associative array i

...

当测试发布时,我使用迭代遍历收到的问题数组,如下所示: /**

* Processes the form.

*

* @param mixed $entity

* @param array $parameters

* @param String $method

*

* @return mixed

*

* @throws \APIBundle\Exception\InvalidFormException

...

你忘了AS关键字: max(case when status LIKE '%Failed%' then scheduled_start end) Last_Failed,

max(case when status LIKE '%Missed%' then scheduled_start end) Last_Missed,

max(case when status LIKE '%Completed%' then scheduled_start end) Last_Completed,

应该 ma

...

$list = array ($_POST["array"]);

如果$_POST['array']已经是一个数组, Array($_POST['array'])将产生[一个]数组字符串数组。 如果你写print_r($list) ,你会看到类似这样的东西: Array(0 =>

Array(

0 => "0",

1 => "0",

2 => "0",

3 => "0",

4 => "0",

5 => "0",

6 => "0",

7 => "0

...

试试这个(未经测试): $element->setDecorators( array(

'Errors',

'ViewHelper',

array( array( 'wrapperField' => 'HtmlTag' ), array( 'tag' => 'div', 'class' => 'input' ) ),

array( 'Label', array( 'placement' => 'prepend' ) ),

array( array( 'wra

...

您收到错误,因为$pages是一个数组。 看起来你想要吐出该数组中的项目数,在这种情况下你应该用count($pages)替换$pages 。 echo '

', $prevlink, ' Page ', $page, ' of ',

count($pages), ' pages, displaying ', $start, '-', $end, ' of ', count($total),

'results ', $nextlink,

...

我最终创建了自己的扩展方法,将MvcHtmlString转换为HtmlTag。 public static HtmlTag ToHtmlTag(this MvcHtmlString html)

{

HtmlTag htmlTag = null;

var doc = new HtmlDocument();

doc.LoadHtml(html.ToHtmlString());

var tag = doc.DocumentNode.

...

当您使用preg_match_all , $matches是一个二维数组。 所以$matches[1]和$matches[3]都是数组。 echo仅适用于数字或字符串,因此当您尝试回显数组时会收到警告。 如果要查看其中的内容,请使用print_r()或var_dump() : print_r($description);

print_r($language);

When you use preg_match_all, $matches is a 2-dimensional array. So $

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值