The Arcive of Official vBulletin Modifications Site.It is not a VB3 engine, just a parsed copy! |
|
#1
|
||||
|
||||
![]()
This seems so simple but I can't figure out the syntax -
In my php script, I have the variables $animal and $shelter set. Let's say animal = 'black cat' and shelter = 'brown dog, black cat, pig' In my vbulletin template I want to do a test to see if $animal contains a phrase that is in $shelter. I have: Quote:
|
#2
|
|||
|
|||
![]()
Ideally you want to use arrays, but given that PHP is hardly an ideal language:
PHP Code:
|
#3
|
||||
|
||||
![]()
Failed:
PHP Code:
Worked: PHP Code:
|
#4
|
||||
|
||||
![]()
I'm curious here. What are you doing with this code? I mean, is it a hack?
![]() |
#5
|
||||
|
||||
![]()
I think his examples are just that, examples. People often provide the simplest example of their problem in order to get the point across. He probably doesn't intend to create some kind of farm-animal hack. :\
|
#6
|
||||
|
||||
![]()
LOL No, I meant how would you use something like that in a hack or somewhere else?
|
#7
|
||||
|
||||
![]()
Ah.
![]() Well, strpos and stripos (case insensitive) are good for finding a substring withing a string. www.php.net/strpos It could be used for many things, like.. finding a username inside a post, etc. For general iteration in a loop, it's best to parse the string into an array (if it's a list) with explode() and then use in_array(), since it's faster. |
#8
|
||||
|
||||
![]()
Ok, I'm not quite sure I understand completely but the part about finding a username inside a post makes sense. Just for yucks, how would you set it up to do something like that then?
![]() |
![]() |
|
|
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|