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.


how do i do this?

Recommended Answers

All 4 Replies

You mean... three four five six seven <?php echo "car" ?> eight nine ten eleven twelve?

Or...<?php echo "three four five six seven" ?> car <?php echo "eight nine ten eleven twelve" ?>?

it should echo

three four five six seven car eight nine ten eleven twelve

the keyword is car. so i want to echo 5 words infront and behind of it and including car .... so for any keyword i do it displays a description.

I am not sure I understand what you are trying to do. When you say "keyword", what do you mean? Is this keyword just text on the page? Is it a link? Is it a keyword in a search? You need to be more specific.

its for a search engine ..

just say the user types car in a form. it retrieves car from the keywords column.


for result description i want it to display car, with a couple words before it and a couple words after it.. so the user can tell what the result is about. i've stopped using meta tags description because not all websites have meta tags set.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.