Php 回音
你好,我试着只回显50个字母,但我的代码中有些地方不正常,有人能看看出了什么问题吗Php 回音,php,Php,你好,我试着只回显50个字母,但我的代码中有些地方不正常,有人能看看出了什么问题吗 <?php $id=18; $result=mysql_query("select * from article where id='$id'"); $row=mysql_fetch_array($result); $row = substr($row, 0,50); ?> <?php echo $row['info_en']; ?>
<?php
$id=18;
$result=mysql_query("select * from article where id='$id'");
$row=mysql_fetch_array($result);
$row = substr($row, 0,50);
?>
<?php echo $row['info_en'];
?>
您想在数组中添加什么?你可能是说
$row['info_en'] = substr($row['info_en'], 0,50);
如果您尝试substr
一个数组,您将得到字符串“Array”
,如果您尝试将其引用为数组,您可能不会得到任何有意义的结果。代码中存在逻辑错误,请使用下面的代码
<?php
$id=18;
$result=mysql_query("select * from article where id='$id'");
$row=mysql_fetch_array($result);
$row['info_en']= substr($row['info_en'], 0,50);
?>
<?php echo $row['info_en'];
?>
不能对数组应用substr()
;它将只对字符串'Array'
进行操作。