aQ Posted July 3, 2007 Share Posted July 3, 2007 Hello! I have a variable ( $theProgram[name], found in a database, contains "MyProgram" ), and I have another one ($program[name], also found in a database, contains "CATEGORY: MyProgram"). I want to search for $theProgram[name] inside $program[name], and if I find it, I want to print out $program[information]. I don't know if this is possible, but help me if you can. Quote Link to comment Share on other sites More sharing options...
per1os Posted July 3, 2007 Share Posted July 3, 2007 <?php if (eregi($theProgram['name'], $program['name'])) { echo 'String was present.'; }else { echo 'The string was not present'; } ?> Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted July 3, 2007 Share Posted July 3, 2007 Dont mean to be picky, but you should use the strstr() function for this as its faster. Quote Link to comment Share on other sites More sharing options...
per1os Posted July 3, 2007 Share Posted July 3, 2007 Dont mean to be picky, but you should use the strstr() function for this as its faster. You can, but the speed difference is very minute for 1 record. That and with strstr() you need to make sure you use the === false parameter. Either way works, I just hate using the === operator to check false variables, they bug me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.