|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Reg expression needed??
Hi,
I've got an interesting question for those who can answer it. I'm retrieving some content from a DB but I would like to get first couple sentenances from the content and display this, I don't for sure if I have to use a regular expression to do this, but any assistance would be much appreciated. Thanks. ![]() |
|
#2
|
||||
|
||||
|
Try using substr() instead. Using "substr(0,100,$str)" gets the first hundred characters of the $str variable, to which you can append "..." or some other marker indicating that users can click for more details.
|
|
#3
|
|||
|
|||
|
Well,
If you do substr() once the information is in PHP you could be using extra system resources, it depends on the ammount of data retrieved. I will better recommend using string functions from MySQL... SELECT SUBSTRING_INDEX(textfield,' ',3) as sentences FROM table where field='criteria' That will give you the first 3 words from the text field, you can replace the "3" to fit your word-count preferences. Hope it helps ![]()
__________________
The deal is not to know everything, but to know the email of the one who does. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Reg expression needed?? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|