Re: match an array value with a word
From: Luciano Tolomei (tolomei_at_newmediatrio.it)
Date: 07/27/04
- Next message: Luciano Tolomei: "Re: quotes from form input + MySQL insert query"
- Previous message: Luciano Tolomei: "Re: form button names as variables"
- In reply to: george: "match an array value with a word"
- Next in thread: steve: "Re: Re: match an array value with a word"
- Reply: steve: "Re: Re: match an array value with a word"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 27 Jul 2004 23:05:42 +0200
if i have undestanded what do you mean, you can do in this way:
$primary_list = array("apple","and","pear","firewood");
$changing_array = array( "apple" => "<a href=apple.htm",
"pear" => "<a href=pear.htm>");
$secondary_list = change_my_array($primary_list,$changing_array);
/* our function */
function change_my_list($a,$b)
{
$c = array();
foreach ( $a as $key => $value) {
if (isset($b[$key])
$c[$key] = $b[$key];
else
$c[$key] = $value;
}
return $c;
}
george wrote:
> Could someone help me?
>
> I'm trying to read an array and if one of the values == a word, then
> assign a new value to it.
>
> In other words if one of the values is 'apple' I need to assign a <a
> href=apple.htm> to it. But if it's 'pear' then assign <a
> href=pear.htm>. Meanwhile, ignore 'firewood' and 'and' values.
>
> Help is greatly appreciated.
>
> Cheers!
- Next message: Luciano Tolomei: "Re: quotes from form input + MySQL insert query"
- Previous message: Luciano Tolomei: "Re: form button names as variables"
- In reply to: george: "match an array value with a word"
- Next in thread: steve: "Re: Re: match an array value with a word"
- Reply: steve: "Re: Re: match an array value with a word"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]