Jump to content


Photo

Character count


  • Please log in to reply
2 replies to this topic

#1 realjumper

realjumper
  • Members
  • PipPipPip
  • Advanced Member
  • 399 posts

Posted 13 March 2006 - 10:39 PM

Hmmm...seems my post got lost....sorry...here it is....


Hi,

I have several sentences in my db (in the 'sentence' field) and I want to display an entire sentence. So far so good. I also have a field "Start" and a field "Finish". In the following sentence...'the quick brown fox jumps over the lazy dog'...I wish to display the part on the sentence that corresponds to the reurned "Start" and "Finish" numbers. So, in the above sentence, the number 5 is returned from the "Start" field and the number 9 is returned from the "Finish" field. What I wish to display is.....'the quick brown fox jumps over the lazy dog' and 'quick'. Is this possible? If it is, could someone point me in the right direction please?

Many Thanks,
Neil

#2 realjumper

realjumper
  • Members
  • PipPipPip
  • Advanced Member
  • 399 posts

Posted 13 March 2006 - 11:28 PM

never mind.....I have it figured out by using substr(). The next problem is going to be making a formula to suit the 2 byte Japanese character set...but that's another story!!!

Thanks.

Neil

#3 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 13 March 2006 - 11:35 PM

Use the substr function:

$start = 5;
$end = 9;

$str = "the quick brown fox jumps over the lazy dog";
echo $str . "<br />";
echo substr($str, $start, ($end - $start));





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users