|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Grabbing a string in between two strings
Can somone tell me how or write me a function that will grab a string in between two strings?
|
|
#2
|
|||
|
|||
|
What exactly do you want? Could you give an example please?
-KM- |
|
#3
|
|||
|
|||
|
For example, im the .tmpl file the content is:
[forum_listcat] <table> {content} </table> [/forum_listcat] [forum_listtopics] <table> {content} </table> [/forum_listtopics] I need the example to grab the string in between the brackets, [forum_listcat] [/forum_listcat] That part will only return <table> {content} </table> |
|
#4
|
|||
|
|||
|
Ok here are some thoughts about how I would go about this -
1) You could use an xml file format instead, then one of the many high quality xml parsing tools available to do this rather than writing your own. 2) Create yourself a function that accepts the open and close tags and finds the occurances of them using strpos and then substr to get whats in between. 3) Some kind of clever regex which I'm sure is applicable here but personally I hate them and generally refuse to acknowledge they exist .Hope one of these is of some use, -KM- |
|
#5
|
|||
|
|||
|
Thx, I have successfully made an working function!
If anyone wants the code just ask for it here |
|
#6
|
|||
|
|||
|
Wait.....Nevermind. The new function I made doesn't work correctly. Here's the code:
PHP Code:
When you call this function more than once, it messes up. I used this: PHP Code:
with the content in skin.tmpl: PHP Code:
Here were the results: PHP Code:
Does anyone know how to fix this problem? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Grabbing a string in between two strings |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|