From bbd691dd58b95a6069d0eef322cef0b41317b01c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=91=9E=E9=98=B3?= <2982337961@qq.com> Date: Mon, 16 May 2022 22:59:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20220516-php\346\225\260\347\273\204.md" | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 "\346\235\216\347\221\236\351\230\263/20220516-php\346\225\260\347\273\204.md" diff --git "a/\346\235\216\347\221\236\351\230\263/20220516-php\346\225\260\347\273\204.md" "b/\346\235\216\347\221\236\351\230\263/20220516-php\346\225\260\347\273\204.md" new file mode 100644 index 0000000..fd749ff --- /dev/null +++ "b/\346\235\216\347\221\236\351\230\263/20220516-php\346\225\260\347\273\204.md" @@ -0,0 +1,41 @@ +```php +"; + +//至少对3个字符串函数进行应用 +$abc = "abc eig didi"; +//第一种 +echo substr($abc,7,5);//截取一个字符串的部分 +echo substr($abc,5);//截取一个字符串后面几位数 +//第二种 +echo strlen($abc);//函数,获取字符串长度 +//第三种 +echo trim($abc);//函数去除字符串左右两端的空格 +echo "
"; + +// 3、写一段程序,创建一个数组,其元素内容为从1到20的所有整数,并输出该数组。 +$a = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]; +foreach ($a as $c){ + echo $c.""; +} +echo "
"; + +// 4、写一段代码,查找数组中是否存在某一个指定的元素,如果存在则返回数组的索引。 +$a = [10,20,30,40,50]; +echo array_search('30',$a); +echo "
"; +//5、写一段程序,创建一个关联数组,其元素是姓名,年龄,性别等个人信息,并输出该数组。 +$arr = array("name"=>"牛逼王","age"=>"18","sex"=>"男"); +foreach($arr as $s => $v){ + echo $s.=$v; +} +``` + -- Gitee