Page 1 of 1

Searching An object

Posted: Sun Apr 09, 2006 11:38 pm
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]

Posted: Sun Apr 09, 2006 11:42 pm
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().

Posted: Sun Apr 09, 2006 11:53 pm
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?

Posted: Mon Apr 10, 2006 12:21 am
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.

Posted: Mon Apr 10, 2006 12:31 am
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.