Limiting Words

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:


Limiting The String Length By The Number Of Words?

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?

i have array :

PHP Code:
$array1= array("donkey","cat","****"); 

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?

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.


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?

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.


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.

$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

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

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?

$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:

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


View 14 Replies View Related

Replace Words - Ignore Words Between Brackets?

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>';


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:


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?

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%-


From this keyword list:

sit amet


I'd like to result in:

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


View 2 Replies View Related

Converts Singular Words To Plural Words

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?

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.



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?

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


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?

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


Now i have this regular expression:


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)

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).

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

View 9 Replies View Related

Page Limiting

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

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

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

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

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

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>
do { ?>
<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>
} while ($myrow = mysql_fetch_array($result)); ?>
<? } else {
echo "Sorry, no records were found";
} ?></td>
<td width="5%">&nbsp;</td>

View 3 Replies View Related

Limiting Text

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:


$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

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:


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


View 2 Replies View Related

Limiting Products

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

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 ..

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>?

I have the following HTML output;

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


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


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?

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)

View 4 Replies View Related

Limiting Input!

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

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

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

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

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

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

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:


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

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

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

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

//Start of Last X torrents mod

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

View 5 Replies View Related

Limiting A Table Size

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

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

Copyrights 2005-15, All rights reserved