General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 24th, 2002, 10:15 PM
Angry Coder Angry Coder is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2002
Posts: 2 Angry Coder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation How to extract data from a variable between two separators?

Hi,

Let's say I have the fallowing structure:

PHP Code:
<?php

$article 
"Ok.. some text here...

(start)
first * second
third * forth
fifth * sixth
and * so on
(end)

some other text here...
"
;

?>


And I want to extract what's between (start) & (end) and put the result into a new variable.

The fallowing code is only working when all the data on the same line!

PHP Code:
if (preg_match("/\(start\)(.+?)\(end\)/"$content$match))
{
    print 
$match[1];



Thanks in advance.

Reply With Quote
  #2  
Old December 25th, 2002, 06:14 PM
invoke invoke is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 6 invoke User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You can try using explode()
PHP Code:
 $text "Ok.. some text here...";

$newText explode("...",$text);

echo 
$newText[1]; // Echo's "some text here" 

This creates an array of strings using the first part of explode as a separator.

Is that what you're trying to do?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > How to extract data from a variable between two separators?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway