Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Snip At End Of A Sentence


I am currently snipping after 145 characters, but really mean "go about 140 characters in then snip at the next full stop" (full stop=period for US readers!). This is what I am using now:

function snip($entry) {

$chars = 145;
$entry = $entry." ";
$entry = substr($entry,0,$chars);
$entry = substr($entry,0,strrpos($entry,' '));
$entry = $entry."...";

return $entry;

}
echo snip$entry;

Can this be done?




View Complete Forum Thread with Replies

Related Forum Messages:
Html Page - <snip>
im trying to make this option: <snip> a little more easy by instead of having the user click on a number which takes them to an anchor on an html page- having them rather enter in the number of their bday in a field and when they hit enter have the prediction displayed on the page. however i have no clue about php. i do not even really know what question to ask to search for a tutorial about this. really i just want to be able to have a user enter in a number in a field and upon hitting enter have that number pull up and display data from a text file.

View Replies !
Warning: (snip Query) [function.require]: Failed To Open Stream: No Error In C:wwwdocrootphpMyAdmin-2.8.0.2
I got what I needed to do done, but I came across this error using phpMyAdmin and I'm curious if anyone has seen anything like this before or has any guess as to what it's supposed to mean:

Warning: (snip query) [function.require]: failed to open stream: No error in C:wwwdocrootphpMyAdmin-2.8.0.2 bl_replace.php on line 275.

View Replies !
Sentence Replaced
How am I able to randomly replace words with one of the list of words coming from a text file? Each line serves one possible random word to replace? Example: Quote:
inside the synonym.txt has word options per line to replace

help,assist,serve,aid
happy,felicitous,glad

Quote:

NY Times Rss Feed - Before

<title>West Village Help: A Plea Rarely Heard: Fewer Spots for Cars</title>
<title>Good Eating | East Village: When Roaming for Ramen assist workers</title>
<title>College Point: A Taste of History, When are students glad?</title>
Quote:

NY Times Rss Feed - After

<title>West Village aid: A Plea Rarely Heard: Fewer Spots for Cars</title>
<title>Good Eating | East Village: When Roaming for Ramen help workers</title>
<title>College Point: A Taste of History, When are students happy?</title>

View Replies !
Extracting A Whole Sentence
Assume that we have a long string, say a paragraph like:

"sentence1. sentence2. sentence3... This is the sentence containing keywords. sentence5. sentence6...."

I know how search and locate the keywords. My problem is to extract the complete sentence that contain my keywords. That is to say, I will search the string, find the keyword(s), and extract only the sentence with my keyword(s) in it.

View Replies !
First Letter Of Sentence
I am in the process of making a function, what this function will do,is take a body of text, and strip it down, and bold all the words in the array of words. A word can be bold in in the center of a sentence, so what I would like to know, is how to find the the position of the first letter of the bold word, and go backwards until I find the first letter in the sentence. This letter will start the text of the displayed content, and will show 50 words, or the first two sentences.

View Replies !
Save Sentence As An Array
I would like to split a sentence in characters:

Example:
$sentence = "hello world";

then $sentence[4] would be "o"

How?

View Replies !
Query The First 4 Words In A Sentence
I want to use Mysql to query the first 4 words in a long sentence & display the results. A sample of the long sentence is like this:- A big brown cat crossed the small blue sea.

In this case, I want Mysql to pick up A big brown cat & display the results. The query should be case insensitive & each word is separated with a blank space. Code:

View Replies !
How To Display Every Sentence With A Checkbox Beside It?
how to display every sentence with a checkbox beside it? and do i need a row to form a sentence in the table? can i separate the words in displaying it from a column of the table and not necessary to form new row just to get a sentence??

View Replies !
Display A Part Of A Sentence
I have a table cell, it is limited to 100px. Here I need to display a title which I select from the DB. But if the title is too long, it is being displayed in 2 or more lines, as the cell width is limited. I'd like to display the title in a shortened way. For example:

"This is a title example for this thread" should be displayed as "This is a title..."
so it won't exceed one line. How can I do this?

View Replies !
Crop Sentence Repeat
Im am trying to crop a sentance using php and a repeat region but the code I have works for the first item but he second one sends an error. Here is the code

<?php do { ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="middle" class="toc_img"><?php echo $row_rsFeature['Photos']; ?></td>
<td valign="top" class="toc_desc"><span class="toc_headers"><?php echo $row_rsFeature['title']; ?></span><br /><?php
function CropSentence ($strText, $intLength, $strTrail)
{
$wsCount = 0;
$intTempSize = 0;
$intTotalLen = 0;
$intLength = $intLength - strlen($strTrail);
$strTemp = "";
if (strlen($strText) > $intLength) {
$arrTemp = explode(" ", $strText);
....

View Replies !
Extract Each Word From The Sentence And Echo It
Say for e.g, i have a sentence: "Hello, my name is Johnny and I like DVD's". How do I extract each word from the sentence and echo it? and also, i want remove any ' from any words, and also if the word ends in s, i want it to remove the s. so with this sentence it shud echo:

View Replies !
Retrieving From Database The First Word Of A Sentence
I have a column named 'name' in my table 'TEAM'(Using Mysql).I have entered values such as

Martin Davis
Kiran Rathore
Naveen krishnan
Prajith V M

I want these values to be retrieved in a PHP form as

Martin
Kiran
Naveen
prajith

View Replies !
Convert A Long Sentence Into Words/string
how to convert a sentence into strings Eg. "I am just a beginner in this PHP" into new lines as follows:

I
am
just
a
beginner
in
this
PHP

View Replies !
How To Put Diffentent Sentence Into Differnt Rows In TextArea
how to put diffentent sentence into differnt rows in TextArea? For eaxmple, i will select all data about topic from database, and display them onto a TEXTAREA. But i want the different topics into different rows. How i can do that?

<form>
<TEXTAREA cols="50" rows="10" wrap=off>

<?
while($row = mysql_fetch_array($result))
echo $row['Topic'];
?>

</TEXTAREA>
</form>

View Replies !
How Do I Find A Word In A Sentence From The List Of Words In An Array?
I have few list of words (needle) I want to find in a sentence (haystack). After a word is found, how would I echo that word? Is there a way to have a multi array so:

if the sentence contains word1,word2 or word3 then echo "coding"
if the sentence contains word4,word5 or word6 then echo "forums"

<?php
$title_of_the_item = "This would be the sentence being pulled.";
$words_from_title = explode(" ", $title_of_the_item);

$word = array("structure", "php", "sentence", "pulled");

if(in_array($word,$words_from_title)){
//even though two words are found in the array, use only 1
}
?>

View Replies !
How To Remove "comma, Full Stop" From A Sentence
I have sentences as follow:

$quote[1] = "To be or not to be, that is the question.";
$quote[2] = "Love looks not with the eyes, but with the mind.";
$quote[3] = "Love all, trust a few. Do wrong to none.";

now I would like to do the following,

1) for each quote[$i], remove all ","(comma) or "."(full stop)...does anyone know how? I have the following code but it does not work. What should I write in $patterns?

for ($i=1; $i<4; $i++)
{
$quote[$i] = strtolower($quote[$i]);
echo "$quote[$i]<BR>";
$pieces = explode(" ", $quote[$i]);
for ($j=0; $j< (count($pieces)); $j++)
{
echo "$pieces[$j] ";
$patterns = ".";
$replacement = "";
print preg_replace($patterns, $replacement, $string);
echo "$pieces[$j] <BR>";
}
}

2) also, I would like to count a) number of frequecy of each term (e.g. "to" has a frequency of 2 in qoute[1]) and b) number of frequency for all three quotes (i.e. "to" has frequency = 3)

but I have no idea how? can anyone please give me an idea?

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved