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:[EMAIL PROTECTED]] 
Sent: Tuesday, July 30, 2002 8:37 AM
To: [EMAIL PROTECTED]
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



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to