Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
neralex
The Mouse Is Extension Of Arm


Joined: Aug 22, 2007
Posts: 1295
Location: Germany

PostPosted: Sun Mar 02, 2014 9:10 am Reply with quote

In a text of a database field i have a unique string and i want remove all characters that follow to the end of the text. But all that follow to the end is dynamicly created and different in each entry.

Example:

Code:
 my needed text ends here<br />

<br />
unique string<br />
<a href="file-a.php>aaa</a><br />
<a href="file-t.php>ttt</a><br />
<a href="file-x.php>xxx</a>


Is it possible to catch all characters after my 'unique string' as one string? I have it tried with preg_match but it seems i can only catch a string between some characters but not until to the last character. Exists here another way?


Last edited by neralex on Mon Mar 03, 2014 9:03 am; edited 1 time in total 
View user's profile Send private message
nuken
RavenNuke(tm) Development Team


Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina

PostPosted: Sun Mar 02, 2014 10:13 am Reply with quote

What php version are you running? If you are using 5.3+ stristr() might work for you.

Code:


stristr($text, $string, true);

_________________
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Send e-mail Visit poster's website
wHiTeHaT
Life Cycles Becoming CPU Cycles


Joined: Jul 18, 2004
Posts: 576
Location: Netherlands

PostPosted: Sun Mar 02, 2014 4:34 pm Reply with quote

it is a little unclear to me of what exactly you want.

From what i understand:

my needed text ends here<br />
<br />
unique string<br />
<a href="file-a.php>aaa</a><br />
<a href="file-t.php>ttt</a><br />
<a href="file-x.php>xxx</a>


Do you need all the text in red?
ifso , are you able to put that particular text inside an html element?
For example a div:

my needed text ends here<div class="required_after" style="display: none;"><br />
<br />
unique string<br />
<a href="file-a.php>aaa</a><br />
<a href="file-t.php>ttt</a><br />
<a href="file-x.php>xxx</a></div>

If you only need it to show you could use jquery:
Code:


$( "div.required_after" ).show();


If the jquery methode is not suitable and wants pure php you forced to use a delimiter let's say a curly bracket
you need to use explode:
Only registered users can see links on this board! Get registered or login! <--running example
Only registered users can see links on this board! Get registered or login! <--RAW code
Only registered users can see links on this board! Get registered or login! <---PLAY with the code Wink

if you want the blue... yeah well that is selfexplaining.
 
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
neralex
PostPosted: Mon Mar 03, 2014 8:40 am Reply with quote

nuken, thx but i found a working solution in php with a mix of preg_match, str_replace and substr.

wHiTeHaT, i can't add a div around these codelines because its a article database with more than 1000 entries and i would have to add it in all entries - that is simply not possible. It was impotant on the server-side with php and not on the client-side with jquery.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©