PHP中如何更新数组
原文链接:http://www.phpdo.net/index.php/20100410/55.html
在PHP中更新数组的内容可以直接指定键名并且对该键名赋值。 例如:
<?php
$php = array(“php”,”phpdo”,”phpdo.net”);
$php[2] = “www.phpdo.net”;
print_r($php);
?>
结果: Array ( [0] => php [1] => phpdo [2] => www.phpdo.net )
相关文档:
函数原型:mixed str_replace(mixed needle,mixed new_needle,mixed haystack[,int &count]);
needle:要被替换的字符串,new_needle:替换用的字符串,haystack:操作字符串,count:替换次数【可选参数】
我们重点试验前三个在使用数组是的执行方式:
&n ......
<?php
$s = "new string";
//下面双引号字符串中的符号"$"未做转义,因此$s将被替换成其变量的值
$str_1 = "双引号指定的字符串,$s";
//下面双引号字符串中的符号"$"做了转义,因此$s原封不动,不会被替换为变量$s的值
$str_2 = "双引号指定的字符串,\$s";
//单引号字符串中的"$"不用做转义即可原样输出
$str_3 ......
<html>
<head>
<script type="text/javascript">
<!--
function confirmDelete()
{
return confirm("Are you sure you wish to delete this entry?");
}
//-->
</script>
</head>
<body>
<% $var1 = 2;%> ......
Warning
: Illegal offset type in
Warning
: Illegal offset type in isset or
empty in
前几天写程序的时候碰到一个这种错误提示
如果你使用这样的表示方法如下:
$arr = array();
class a
{
}
$o = new a;
echo $arr[$o];
就会出现上面的错误提示,因为不能使用实例化的对象来作为数组的索引,或者在使用i ......