Search a list of records: Difference between revisions

From Rosetta Code
Content added Content deleted
(Created page with " =={{header|Perl}}== <lang perl>if(grep $_ eq $needle, @haystack) { print 'Found'; }</lang> =={{header|PHP}}== <lang PHP>echo in_array('needle', ['hay', 'stack']) ? 'Found...")
 
No edit summary
Line 1: Line 1:
{{draft task}}

=={{header|Perl}}==
=={{header|Perl}}==



Revision as of 04:48, 10 October 2015

Search a list of records is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.

Perl

<lang perl>if(grep $_ eq $needle, @haystack) { print 'Found'; }</lang>

PHP

<lang PHP>echo in_array('needle', ['hay', 'stack']) ? 'Found' : 'Not found';</lang>