zoukankan      html  css  js  c++  java
  • php知识点总结(一)

     

    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);

    ?>

  • 相关阅读:
    微服务使用总结
    Xftp的下载安装,以及如何使用XFtp连接虚拟主机/服务器
    "net.sf.hibernate.PropertyValueException"
    "net.sf.hibernate.PropertyValueException"
    "net.sf.hibernate.PropertyValueException"
    XMLHttpRequest 请求java部署的webservice 跨域问题
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
  • 原文地址:https://www.cnblogs.com/iriliguo/p/php.html
Copyright © 2011-2022 走看看