Re: 2 questions: Search in array and detect JS

From: Date: Sat, 15 Apr 2006 10:17:39 +0000
Subject: Re: 2 questions: Search in array and detect JS
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-234026@lists.php.net to get a copy of this message
Ryan A wrote:
1) Is it possible to detect JavaScript via php... and yes I do know that JS is client side while PHP is server...but how else to do it? The reason I ask is before serving an AJAX page I would like to make sure JS is enabled, if not, serve the other "normal page"... I am sure I am not the first person to come accross this little problem, how did you solve it?
The way I do this is to serve the 'notmal page' first, but with the following snippet of JS in it... <script language="javascript"> <!--
    location.href = '/url/for/ajax/page.php';
--> </script> That way if they have JS enabled they'll get sent to the AJAX page. If not they stay on the 'normal page'.
2) How can I search in an array for a particular word? eg: in an array "movie" I have this kind of data: movie_name=> some movie cast=> Jim Carrey, Richard Pryor, Eddie Murphy I want to search on either "Richard" or "Richard Pryor" (must be case insensitive too) something like a SELECT with a LIKE %% statement I have been fooling around with in_array() but not getting anywhere fast..... am I on the right track? Links, code examples or advise would be as always....appreciated.
You should be able to craft some combination of array_walk and a custom function that checks each element with stristr to do what you need. -Stut

« previous php.general (#234026) next »