Searching An object

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m0nk3yb0y
Forum Newbie
Posts: 14
Joined: Mon Feb 20, 2006 11:07 pm

Searching An object

Post by m0nk3yb0y »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


I'll try to make this clear as i can. I want to search through an object and return match or no match depending on whether the object contains any data.

something like this

Code: Select all

if (some_search_function here)
			{
			echo "<td><p>Match</p></td>";
			}
			else
			{
			echo "<td><p>No Match</p></td>";
			}
Any help appreciated


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Search through an object for what? An object can contain variables (usually called properties). You can "search" them in the same way you would any group of variables. If you want to see if the object exists then you would use isset().
(#10850)
m0nk3yb0y
Forum Newbie
Posts: 14
Joined: Mon Feb 20, 2006 11:07 pm

Post by m0nk3yb0y »

Search through an object for what?
I want to search the object to see if it contains any text.

Can I use preg_match() with objects?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Search the properties?

get_class_vars() and get_object_vars() can be used to retrieve information on properties in classes and objects, respectively. It is possible to use preg_match() against the retrieved property names.
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

m0nk3yb0y wrote:
Search through an object for what?
I want to search the object to see if it contains any text.

Can I use preg_match() with objects?
What do you consider text. Give us sample example of object with text to see what exactly you want to catch.
Post Reply