Re: [PHP] Array question

2007-02-26 Thread Hap-Hang Yu

Try:

$fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');
$search = 'apple';

foreach($fruit as $key => $val) {
 if ($val == $search) {
echo "$search found: array key is $key, value is $val";
 }
}

2007/2/27, Gerry D <[EMAIL PROTECTED]>:

I have a question on how to retrieve the value that corresponds to a
key in an array.

$fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');

$key = array_search($c, $fruit);
if ( $key === FALSE )
$n = $c;
else
{
$n = $fruit[$key];  // how to get the value???
}

the array_search works ok, but how do I get the value?

all I get back is 'a' or 'b', not 'apple' or 'banana'...

TIA

Gerry

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





--
--
Hap-Hang Yu, Jay

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



Re: [PHP] PHP 5.2.1: Some scripts are being parsed, but most aren't

2007-03-27 Thread Hap-Hang Yu

Check your php files. Make sure the PHP code are enclosed in the tag
, not 

There's a php.ini option to accept . It's: short_open_tag = On

2007/3/28, Eddie <[EMAIL PROTECTED]>:

Hi all,

Previously, I had installed Apache 1.3.37 with PHP 5.2.1 as
a static module on Ubuntu 6.06. I am having a problem where,
for some reason, some of my PHP scripts just show source
code, while some are parsed.

In the meantime, while trying to get this issue fixed, I
decided to upgrade to Ubuntu 6.10, the latest Ubuntu
release, to see if that helped the problem.

As stated above, some of my PHP scripts just show source
code both in Apache and the CLI, and some are actually
parsed. I know this is not an Apache problem since I get
the same results in the CLI.

This is a paid script, and I am unable to post code, but
in generic terms, I have narrowed it down to the following
code.

require_once($(DIR VARIABLE NAME HERE)."/(NAME HERE).php");
include_once("includefilenamehere.inc");

The first line of the code completely makes it show the
line of code, and the second line makes it show the
include file, even if the second line is executed without
the first line. Unfortunately, this is the only information
I've been able to locate in my debugging.

For debugging purposes, I also downgraded to PHP 4.4.6, and
I had the same exact problem. It looks like it is a problem
with a library possibly? An strace reports that PHP is trying
to search for libraries in /usr/local/mysql/lib/mysql, but if
I put them in there, it still doesn't function correctly.

Any help is more than appreciated.

Thank you very much,

Eddie

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





--
--
Hap-Hang Yu, Jay

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