PHP第十三课2:PHP字符串对象的操作
<!doctype html> <html lang="en"> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> <style type="text/css"> body{ font-size:30px; margin-left:80px; } </style> </head> <body> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <?php //php中 字符串对象 的 操作 (我怎么在项目中去使用这个对象里的各个方法或属性) //对象 = 属性+方法 //(4)检索字符串 //strstr() 检索 一个字符串 是否在 另一个字符串里面 存在 $res = strstr("hello world","world",true); var_dump($res); //(5)分割字符串 //explode() 函数: 将字符串 换成 数组 $str = "新款连衣裙 四件套 潮流T恤 时尚女鞋 短裤 半身裙 男士外套 墙纸 行车记录仪 新款男鞋 耳机 时尚女包 沙发"; $data = explode(" ",$str); echo "<pre>"; print_r($data); echo "</pre>"; //(6)合成字符串 //implode() 将数组 转成 字符串 $arr = array("陈靖","张帅","赵琦","吴家卫"); $str3 = implode("+",$arr); var_dump($str3); ?> </body> </html>
吐槽一下

还没有留言,还不快点抢沙发?