如何使用Php搜索和回显特定部分? [英] How to Search and echo Specific Part Using Php ?

查看:56
本文介绍了如何使用Php搜索和回显特定部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要php代码搜索一段我在变量中提供的代码,然后从代码起点回复大约40个单词的文字。



例如,我的代码存储在一个变量中:



  <   html     xmlns   =  http://www.w3.org/1999/xhtml >  
< head > < meta charset = utf-8 / > < title >
Dotcabs
< / title > < meta 名称 = viewport 内容 = width =设备宽度,高度=设备高度 / > < link rel = stylesheet href = css / style.css / > < link rel = stylesheet href = css / responsive.css / >
< script src = js / jquery-1.11 .1.js > < / script >
< script src = js / script.js > < ; / script >
<! -
< script src =https://maps.google.com/地图/ API / JS传感器=假>?< /脚本>
- >

< script src = https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&sensor=false > < / script >
< script src = js / places-search-box.js > < / script >

< link rel = stylesheet href = http:// code .jquery.com / ui / 1.10.4 / themes / smoothness / jquery-ui.css / >
< 脚本 src = http://code.jquery.com/ui/1.10.4/jquery-ui.js > < / script >
< script < span class =code-attribute> src = js / jquery-ui-timepicker-addon。 js > < / script >





我想找到字代码.jquery然后回显匹配术语中的前30个或更多单词,



在这种情况下,我需要搜索code.jquery,它现在在代码中所以现在,我想回复50或我选择的任何字符:

 code.jquery.com/ui/1.10.4/jquery-ui.js 







感谢任何帮助!

解决方案

尝试通过阅读这两个函数来自己:

1.使用 strstr [ ^ ]找到第一次出现的字符串。

2.然后,使用 substr [ ^ ]至从#1返回字符串的一部分。

还有更多字符串函数 [ ^ ]可以满足您的各种需求

Hi , I want php code to search a piece of code which i made it available in an variable , and then echo around 40 words of text from the code starting point .

For Example , My code is stored in an variable as :

<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta charset="utf-8" /><title>
    Dotcabs
</title><meta name="viewport" content="width=device-width, height=device-height" /><link rel="stylesheet" href="css/style.css" /><link rel="stylesheet" href="css/responsive.css" />
    <script src="js/jquery-1.11.1.js"></script>
    <script src="js/script.js"></script>
    <!--
    <script src="https://maps.google.com/maps/api/js?sensor=false"></script>
    -->
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places&sensor=false"></script>
    <script src="js/places-search-box.js"></script>

    <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css" />
    <script src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
    <script src="js/jquery-ui-timepicker-addon.js"></script>



I want to find the word code.jquery and then echo the first 30 or More words from the matched term ,

Here in case, I need to search code.jquery , Its present in code so now , I want to echo this upto 50 or any characters of my choice:

code.jquery.com/ui/1.10.4/jquery-ui.js




Any help is appreciated !

解决方案

Try it yourself by reading up on these 2 functions:
1. Use strstr[^] to find the first occurrence of a string.
2. then, use substr[^] to return part of a string from #1.
There are more string functions[^] that you can use for your varied needs.


这篇关于如何使用Php搜索和回显特定部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆