Limiting Words

Apr 22, 2007

I am trying to get a list of news stories from a database and list them, limiting them to a just 100 characters, and rounding them off to the nearest whole sentance, with a Read More » link to read in full. I have written the code, but its not working. Code:

ADVERTISEMENT

Limiting The String Length By The Number Of Words?

Jan 24, 2011

I have a string in the form of "word1-word2-word3-word4-word5-word-6-word7", but I want to shorten it to 5 words only. 

View 11 Replies View Related

$words Array Have Many Words , It Work Only With First Words?

Jul 4, 2009

i have array :

PHP Code:
$array1= array("donkey","cat","****"); 
[code]..

it work some times , but if $words array have many words , it work only with first words , so , what's your opinion ? and it this method is true ? or there are anothr method ?

View 5 Replies View Related

Calculate The Number Of Words/characters Between 2 Given Terms/words?

Apr 7, 2011

Basically - I want to calculate the "Proximity" of various terms. By "proximity" I means Specifically the number of spaces/characters/words that sit between them.

Example:

Terms = Word1 / Word2
Chunk = "blah Word1 blah blah blah blah blah Word2 blah"
Proximity = Word1-Word2:5

THe script would see the 2 terms, locate them and then see the distance based on the words that lay between them. A more advanced version would be to examine the semantic structure - and identify whether the terms occur within the same semantic element, or a sibling, or a parent etc. Thus proximity discovery of terms may be within the same paragraph, or in sequential paragraphs, or under the same "parent" (heading) but otherwise separate etc. Further - introducing things like word stemming/relationships/soundings at a later date may be useful too.

I've looked around the net (Google, here, php forums, php script sites). Not seeing anything like it. I can see tools on some sites that do similar (limited) - usually SEO based tools. I want to be able to apply this to "text" in general ... as I may apply it to uploaded word/txt files etc. I'm not seeing any real examples - so I can only assume it's mroe than a trifle to code it. How would I handle variant order of the words (Word1+Word2 / Word2+Word1)? How could I handle identifying proximity within/outside of the same element/structure?

View 1 Replies View Related

Bold Some Words In A String And Remove Some Unbold Words?

Oct 31, 2009

I am creating an Image Search Engine. Currently, my script does bold the matching words on the keyword. But, some keywords are too long just like the followings. When I search for shah rukh khan, there is an image with the following keyword.

25216d1235653089 shahrukh khan s
wallpaper shah rukh actor

As you see, the above keyword is too long. So, I need it to be like the following one.

[code]....

Currently, I am using the following code but it requires a space before and after the bold tags. So, if the 1st word is bold, it displays the whole keyword.

if(strlen($img_keyword)>30){
$img_keyword = preg_replace('/(.*?) <b>(.*?)</b> (.*?)/us'," <b>$2</b> ",$img_keyword);
}

View 2 Replies View Related

Counting Words And Cut After Specific Total Words

Jul 21, 2001

This is my code to count words in a post: PHP Code:

View 6 Replies View Related

Perform Search Onto Words And Display The 2 Words

Dec 21, 2004

so far on page one it takes word from text box and produces search on datebase for that word then produces correctly over the folling pages using pagination. question is i want it to now perform search onto words and display the 2 words. code is below. :_

$carrymake = (isset($_POST['carrymake']))? $_POST['carrymake'] : $_GET['carrymake'];

$carrymodal = (isset($_POST[carrymodal ]))? $_POST[carrymodal ] : $_GET[carrymodal ];

i want to know now how to include the second varible in this code here:-

// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$prev.'&carrymake='.$carrymake.'"><<Previous</a>&nbsp;'
}

View 1 Replies View Related

Preg_match_all : Replace Multiple Words With Different Words?

Jun 5, 2009

$post[message] is the text of a post from my forum.

I wanted to take out all the text and keep only the text between [TAG1] tags

here is a part of the code i am using to do that:

Code:
<?php
$string = $post[message];
$tag = "TAG1";
preg_match_all("#[".$tag."](.*)[/".$tag."]#Ui", $string, $matches);

[Code]....

View 14 Replies View Related

Replace Words - Ignore Words Between Brackets?

Jun 21, 2010

I'm using an ubb parser to convert several codes within brackets to html codes. I want to use a string replacer aswell to replace some unwanted words.

Now, I'm using this:

foreach($f AS $value) {
$escapeNamesArray[] = '/'.$value['woord'].'/i';
$escapeNamesReplace[] = '<span style="color: gray;">'.$value['vervanging'].'</span>';

[code]....

When I want to replace the word "Hello" to "Hey", everything is working fine. But when I place the word "Hello" between brackets, for example:

[code]...

The word "Hello" is replaced aswell. How can I change the pattern of the preg_replace function to ignore words between brackets?

View 4 Replies View Related

Wrap Words Or Words Sequences Which Have Not Been Already Wrapped?

Oct 13, 2010

I'm trying to wrap words and words sequence from a given list with preg_replace. It almost works, but there are some use cases it doesn't and I can't figure it how. For instance I do this:

// sort by descending length
usort($this->_keywords, function($a,$b){return(strlen($a)<strlen($b));});
// wrapper is -%string%-

[code].....

From this keyword list:

lorem
ipsum
sit amet

[code]....

I'd like to result in:

-Lorem- -ipsum- dolor -sit amet-,
consectetur adipiscing elit. Phasellus
rhoncus venenatis orci sed porta. Sed

[code]....

View 2 Replies View Related

Converts Singular Words To Plural Words

Mar 31, 2010

I am looking for a class that converts Singular words to Plural words. My aim is to take something like Story for a model name and create a Story.php file and a stories.php file. I already have the generator class ready to roll just hoping there is some prebuilt class for converting singular to plural word otherwise i'll start this the most expected ones and work from there.

View 2 Replies View Related

Organize Words So Can Fit The Most Number Of Words In A Given Length?

Sep 25, 2009

I'm looking for a way to do the following. I have a list of words of various char lengths. I have a limited number of chars I can use in a given strings size. I'd like to organize the words to fit as many of them as I can in a given string without going over the limit or cutting any of the words off.

Bobby
Sally
Joe
Sue

[code]....

I have a limit of 140 characters to fit them all in, including spaces. If I have more names than space avail in that string, I'd like to generate another string using the same function as described above until all the names in the list are used.

View 1 Replies View Related

Punctuate Words If It Contains More Then X Number Of Words?

Sep 27, 2010

When a word gets to long it messes the text up.... how can I fix this?

Example:

Make a word with 4 chars like "cats" into "ca..."

How would I do this?

View 1 Replies View Related

Count The Number Of Words Between Two Words?

Jul 21, 2010

How can i count the number of words between two words?

[code]....

Now i have this regular expression:

[code]....

View 3 Replies View Related

Reads In A String And Reverses All Of The Words Inside Of The String (the Words Stay In The Same Position But Are Reversed)

Oct 22, 2010

A function that reads in a string and reverses all of the words inside of the string(the words stay in the same position, but are reversed).

Code:
function(String sentence){
String word="";
String reversedSentence;
for(int i = 0; i< sentence.length; i++){
if(sentence[i] == ' '){
reversedSentence += reverse(word);
word = "";
[Code]....

View 9 Replies View Related

Page Limiting

Feb 15, 2007

I have pages for the results (as you can see 1 2 3 4 and 5) ... how do I get it to where it only shows 4 pages at a time? For eample , it will show

1 2 3 4 5 >> Next then when they get to the 4th page it will then show 5 6 7 8 , for eample .. then when they get on the 8th page it iwll show 9 10 11 12 , and so on. Code:

View 20 Replies View Related

Limiting SQL Rows

Dec 27, 2005

is there a way in MySQL where I can limit the database itself (Not the output) to 10 rows?

what i am aiming to do is on my website have a list of recently added products to the main database and it stores the 10 most recently added products to the database, and removes the oldest record.

View 1 Replies View Related

Limiting An Array

Mar 23, 2005

Is it possible to limit an array? For example to display parts of an array (that has say 22 bits to it) but only display 4 bits of it?

View 1 Replies View Related

Limiting Size

Jun 23, 2006

I have a query that im using in a paginated page

e.g. "select * from news"

what i want to do is for the first page get the first 20 say and then for the second get from 21 to 40 and so on. Is this possible in the query? I can obviously code it up to do the logic in PHP but thats going to be inefficent and people might laugh at me behind my back.

View 2 Replies View Related

Limiting Number

Sep 6, 2006

i'm working on an event listing site. when someone lists an event, they can upload 3 images. Rather than uploading every single image to a single directory, i'd like to break the uploaded images out into a bunch of different directories. otherwise, any attempts to view the contents of the user image folder could result in a really LONG wait as we list a billion images. I'd like to limit the contents of any given directory to a thousand items.

I'd also like to support a very large number of events and images (1 billion? 10 billion?). I realize that many images might overload a single drive on any server, but am still determined to do it. Seems to me that some sort of recursive function might be necessary? It's easy enough to turn an event id into a folder. it's also not so hard to make a new subdirectory so there are no more than 1,000 events in a irectory. what's more difficult is when we exceed 1 million images. then my top level directory would have more than a thousand images in it.

View 7 Replies View Related

Limiting Selection

Jul 2, 2005

I have checkboxes on a form that should only allow up to four selections. What would I need to add to this code to limit the selection to 4. Now it lets you select more than 4.


<td class="resultsColumnName" id="vciColumnTitle" valign="bottom" align="center"><strong>VCI</strong><br>Cushion</td>
<td class="resultsColumnName" id="checkboxColumnTitle" valign="bottom" align="center"><strong><h2>Choose up<br> to 4 Shoes to<br> Compare</h2></strong></td>
</tr>
<?
do { ?>
<tr>
<td class="shoeNameResults"><?=$myrow[product_name];?></td>
<td class="shoeTciResults" align="center" width="30"><?=$myrow[tci];?></td>
<td class="shoeVciResults" align="center" width="30"><?=$myrow[vci];?></td>
<td class="shoeCheckboxResults" align="center" valign="top" height="20"><input type=checkbox name=shoes[] value="<?=$myrow[product_image]?>"></td>
</tr>
<?
} while ($myrow = mysql_fetch_array($result)); ?>
</table>
<? } else {
echo "Sorry, no records were found";
} ?></td>
</tr>
<tr>
<td width="5%">&nbsp;</td>

View 3 Replies View Related

Limiting Text

Aug 15, 2007

I have a field in my database named about and I want to limit the amount of characters outputted (to 100)of this, so I thought it would be done like so:

<?php

$query = mysql_query("SELECT * FROM players ORDER BY RAND() LIMIT 1") or die(mysql_error());
$text = substr($about,0,100);


while($row = mysql_fetch_array($query)) {

echo '<h3>'. $row['player_name'] .'</h3>'."
";
echo '<div class="profile_image"><img src="images_two/odhiambo_delete.jpg" /></div>'
echo '<div class="profile_text">'. $row['text'] .'</div>'."
";

}
?>

However, that does not seem to work, where am I going wrong?

View 2 Replies View Related

Limiting A Selection

Jul 25, 2006

I have a table in my database that contains fields relating to addresses. What I want to do is to give the user a choice to view all the locations from a certain county. As there can be multiple instances of a county in the table how do I ensure the county only gets displayed once. For example in the table I may have 5 entries which are:

Devon
Cornwall
Devon
Devon
Sommerset

When I retrieve all the information from the table I want to display only

Devon
Cornwall
Sommerset.

View 2 Replies View Related

Limiting Products

Aug 8, 2007

I have never been able to figure out how to show more than one product within a table row, and limit my products in that row to whatever. 3 or 4.

View 3 Replies View Related

Limiting To Certain Amout

Dec 3, 2006

Using the substr function I have limited a string to a certain amount of chars. PHP Code:

echo substr($row["refer"], 0, 50);

I have noticed quite a few websites add.

View 2 Replies View Related

Limiting Query Between ..

Dec 28, 2005

How is it possible to limit a query to a designated number of records. not sure if Im wording this correctly.. My table has the first field to "id" it is a INT, primary & is auto increment:

query only to say
id = 655 to 2222 range ?
where 'name' LIKE 'jugs'

View 2 Replies View Related

Limiting <li> Tags In A <ul>?

Mar 16, 2011

I have the following HTML output;

<ul>
<li>Test 1</li>
<li>Test 2.</li>
<li>Test 3</li>
<li>Test 4</li>

[Code].....

Is there an easy way I can do this in PHP?

EDIT:

The data is coming from:

$data = $product->getDescription();

It is stored in the DB as the HTML content, I am currently displaying it using the above code;

View 4 Replies View Related

Limiting Use Of Functions?

Sep 26, 2010

I am currently creating a CMS which will allow PHP code to be used but I need to make sure that certain functions are not used that can ruin the CMS.Basically, I need a way to stop certain functions (like fopen) to be executed. The only problem I have with using str_replace to replace the text is that it also replaces any only occurrence which is not a function.

Example (replacing fopen to void):
$file = fopen("/index.php", "w");
echo "I used fopen!";
Output (PHP)
[code]....

View 4 Replies View Related

Limiting Input!

Jun 20, 2007

I have recently started a project, and I need to limit user input. I need to make it so the user can only make 1 guess per day. It will collect all the users/guesses for one day, then at the end of the day(12 AM) I will drop all the guesses so they can start guessing again. So I just need to know how to make it so they can only make 1 guess. Code:

View 3 Replies View Related

Limiting No. Charcters

Apr 20, 2007

how to limit the number of charcters when displaying something and having the ending as "..." For example displaying news articles and then a link saying Click Here For More Code:

View 3 Replies View Related

Limiting Search

Oct 16, 2007

I have a search result page that is meant to limit the results to 5 per page and then you click next to view the next results (and next for more results and previous for the previous page).

The problem is that when you perform the search it works fine but when you want to go to the next page nothing happens. I think the reason is that it looses the search criteria. Code:

View 4 Replies View Related

Echo 5 Words Before 5 Words After

Mar 21, 2010

I have a keyword "car" in the sentence. one two three four five six seven car eight nine ten eleven twelve thirteen fourteen fifteen. i'd like it to echo three four five six seven car eight nine ten eleven twelve because 5 words before and 5 words after, including car.

View 4 Replies View Related

PHP, MySQL & Limiting Access

Jul 17, 2005

I have a project for work, and I'm not sure how to efficiently do what I
need to do. I'm hoping someone out there can help.

Project is this: I'm creating a web-based interface where people at my
company (operators) can enter data for service calls. All data entered
is run thru one or more PHP scripts for error checking and then stored
in a MySQL database on a server here in the office.

What I'm looking to do is to limit access to certain operators so they
can only do certain functions (ex: add a service call, but not delete
one), whereas admins such as myself would have full access to
everything. Ideally, at some point in the future, we plan to roll this
interface out to our clients so they may do the same features within
their company. Obviously, they would only gain access to data related
to their company, as to protect the privacy of others.

Hierarchy would be something like this:

1. UberAdmins (such as myself)
-Have access to everything and to all commands.

2. Operators
-Have access to everything, but not all commands.

3. Our clients
-Have access to their data only, and to all commands.

4. Our clients' operators
-Have access to their data only, but not all commands.

The difficult thing is that our clients may run several businesses, so
they would have to have access to several groups. In essence, they'd
have multiple groups (their businesses) within a group (their group)
within a group (everything).

What is the easiest and most secure way to do something like this? I'm
not looking for actual code but merely suggestions. Please reply if
there is something I wasn't clear on.

View 2 Replies View Related

Limiting Simultaneous Logins

May 7, 2005

What I am trying to do is to limit the number of simultaneous logins of each registered user. Currently each user will be authenticated against a database and a PHP session will be created for him (say $_SESSION['username']). Then we will check for this session in all pages.

Which solution do you recommend to limit the number of simultaneous logins by each user?

View 1 Replies View Related

Limiting Random Results

Mar 19, 2007

I am trying to echo 3 random articles from my articles table but I would like to echo only articles from within the top 20 most recent ones.

What I mean is. I know how to bring the most recent articles:

("SELECT * FROM $usertable ORDER BY DATE DESC LIMIT 20")

And I know how to bring articles randomly:

("SELECT * FROM $usertable ORDER BY RAND() LIMIT 3")

But I do not know how to do both. Meaning, bring me 3 random articles but limit them to the top 20.

View 8 Replies View Related

Limiting Valid X And Y Positions

Aug 3, 2005

as you can see you get a message in the upper left corner saying "o <-- you are here", now, noice something? Yea your in the OCEAN! I need to make a script that fits the limits of where you can be located to the edge of the land, and if the position go beyond these limits the pointer can simply be placed at the closest edge. Is there a way i can do this, and if so, how?

View 4 Replies View Related

Limiting Access To A Page

Jan 22, 2007

I've got one page in php (let's call it index.php) that from <iframe> calls another page written in php (be it application.php). How can I stop users from calling application.php on it's own? I mean if someone wants to use my application for his own site.

First thing I thought was to use $_SESSION and set some varible in index.php and then check it in application.php. But then some intruder would make an invisible frame with index.php, which will create session varible, and visible frame with application.php. Second thought is to use some kind of time-based hashes but I can't think of anything that can't be fooled.

View 3 Replies View Related

Limiting The Numbers Of Characters

Nov 28, 2006

I have this piece of code to display last ten inputs:

//Start of Last X torrents mod

$sql = "SELECT torrents. * , categories.name AS cat_name, categories.image AS cat_pic
FROM torrents LEFT JOIN categories ON category = categories.id
ORDER BY added DESC LIMIT 10";
$result = mysql_query($sql) or die('No torrents found');
if( mysql_num_rows($result) != 0 ) ..........

View 5 Replies View Related

Limiting A Table Size

Apr 13, 2005

I have a table that I want to have no more than 500 records. This table is ordered by some value. I want to do something like this:

if ( $NumRecords > 500 )
{
DELETE * FROM $table WHERE ($Value < $table[500].Value )
}

What is the correct syntax for doing this?

View 1 Replies View Related

Limiting Folder Size Using Php

Aug 30, 2005

i want to limit the size of my folder. is there any code in php or other language to check the size n limit it or display warning msg.

View 1 Replies View Related

Limiting Connection From A User

Jul 29, 2006

how do i limit a http request from an IP , just like the one used on popular download sites such as rapidshare. where a single user can only download one file at a time.

i wan't to implement this method on my new video blog. can anyone point me to a script that fit the job description?

View 1 Replies View Related

Limiting Number Of Records

Apr 23, 2006

I was wanting to find out how to limit the number of records displayed from a text file. Is there a way to limit the number of lines read from the text file?

View 7 Replies View Related

Limiting The Amnt Of Smilies

Jun 25, 2005

Sometimes when there are many smilies on a page, the page might load slowly, I wonder if there is a nice way to limit the amount of smilies on the post?

View 7 Replies View Related

Limiting Number Of Entries

Dec 6, 2006

I am using a mysql database and using a simple form to input data into the table, but i want it to refuse the data if there is say 30 entries in the database already.

View 1 Replies View Related

Limiting Result Using ORM Kohana?

Apr 14, 2011

I have written code

ORM::factory('cds')->find_all(1, 2);

It is returning all row . But according to documentation it should return 2 row. what's wrong in the code ? [URL]....

View 1 Replies View Related

ADVERTISEMENT