RE: [PHP] searching an array for words starting with 'p'
| From: | Joseph Rosenblum | Date: | Tue, 30 Jul 2002 17:57:19 +0000 |
| Subject: | RE: [PHP] searching an array for words starting with 'p' | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-110385@lists.php.net to get a copy of this message | ||
I don't think there's a builtin that does exactly what you are looking
for, but this will do the trick:
<?php
$array = array ( "pinaeapple", "orange", "passionfruit");
$newar = array();
foreach ($array as $val) {
if ($val{0} == "p") {
$newar[] = $val;
}
}
?>
-Joseph Rosenblum
President, 25th Street Networks
Easy, Reliable PHP Web Hosting at:
http://www.25thstreet.net/
-----Original Message-----
From: andy [mailto:news.letters@gmx.de]
Sent: Tuesday, July 30, 2002 8:37 AM
To: php-general@lists.php.net
Subject: [PHP] searching an array for words starting with 'p'
Hi there,
I am wondering how to search an array for words starting with a certain
character.
E.G:
$word = array('alpha', 'beta', 'php');
I would like to check if there is a word in the array starting with p
Is there alrready a function for this?
Thanx, Andy
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php