博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php知识点总结(一)
阅读量:6614 次
发布时间:2019-06-24

本文共 2004 字,大约阅读时间需要 6 分钟。

 

1.把数组以表格的形式显示

<?php

$array = array(

  '书籍' =>  array( '生活',  '人与自然','动物世界'),

    '体育用品' =>  array( '乒乓球','网球','高尔夫球'),

      '水果' => array( '橙子',  '葡萄','苹果')

);

//创建表格将数组循环输入

    echo '<table border="1" width="600" align="center" >';

    echo '<tr bgcolor="#dddddd">';

    echo '<th>name1</th><th>name2</th><th>name3</th>';

    echo '</tr>';

    foreach ($array as $value)

    {

        echo '<tr>';

//foreach里面嵌套一个for循环也是可以的

        /*for($n=0;$n<count($value);$n++)

        {

            echo "<td>$value[$n]</td>";

        }*/

//foreach里面嵌套foreach

 

        foreach($value as $mn)

        {

            echo "<td>$mn</td>";

        }

        echo '</tr>';

    }

    echo '</table>';

?>

 

2.使用str_ireplace()函数替换查询关键字,当显示所查询的相关信息时,将输出的关键字的字体替换为红色

<?php

$content="白领女子公寓,温馨街南行200米,交通便利,亲情化专人管理,您的理想选择!";

$str="女子公寓";

echo str_ireplace("白领女子公寓","<font color=red>$str</font>",$content);

?>

 

3. 对检索到的用户输入的查询关键字进行加粗描红

 

<html>

<head>

<title> </title>

</head>

<body>

<form id="form1" name="form1" method="post" action="php_03.php">

<input type="text" name="txt" />

<input type="submit" name="ss" value="提交" />

<div><br />

The breakout sci-fi drama took a couple years to make it to air, so it’s perhaps not surprising it will take awhile for another round. The densely plotted, special-effects-filled series is labor intensive, and showrunner Jonathan Nolan and Lisa Joy want to have all 10 episodes written before starting filming. So we’re going to have to wait awhile before we find out what “SW” is all about.

</div>

</form>

</body>

</html>

<?php

error_reporting(0);// 关闭错误报告

 

$txt=$_POST["txt"];

 

$bt=$_POST["ss"];

$wz="

The breakout sci-fi drama took a couple years to make it to air, so it’s perhaps not surprising it will take awhile for another round. The densely plotted, special-effects-filled series is labor intensive, and showrunner Jonathan Nolan and Lisa Joy want to have all 10 episodes written before starting filming. So we’re going to have to wait awhile before we find out what “SW” is all about.

";

echo "<br />";

echo str_ireplace($txt,"<b style='color:FF0000'>".$txt."</b>",$wz);

?>

转载于:https://www.cnblogs.com/iriliguo/p/php.html

你可能感兴趣的文章
Mysql学习第三课-分析二进制日志进行增量备份和还原
查看>>
HDU 6073 - Matching In Multiplication | 2017 Multi-University Training Contest 4
查看>>
如何检测域名是否被微信屏蔽 微信域名检测接口API是如何实现
查看>>
POJ1611-The Suspects
查看>>
Linux下安装Python-3.3.2【转】
查看>>
LeetCode OJ:Merge Two Sorted Lists(合并两个链表)
查看>>
功能测试
查看>>
【BZOJ 1901】Dynamic Rankings
查看>>
PAT (Advanced Level) 1028. List Sorting (25)
查看>>
【转】聚集索引和非聚集索引的区别
查看>>
Github-Client(ANDROID)开源之旅(二) ------ 浅析ActionBarSherkLock
查看>>
eclipse中如何去除警告:Class is a raw type. References to generic type Class<T> should be parameterized...
查看>>
k sum(lintcode)
查看>>
Android 控件属性
查看>>
React-Native 之 GD (十六)首页筛选功能
查看>>
SSISDB5:使用TSQL脚本执行Package
查看>>
asp.net后台进程做定时任务
查看>>
Ural_1671. Anansi's Cobweb(并查集)
查看>>
给vs2012换肤
查看>>
java接口中多继承的问题
查看>>