Click here to Skip to main content
15,886,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :

XML
<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 !
Posted

1 solution

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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900