NYCPHP Meetup

[nycphp-talk] Disappearing data or I've gone mad

Chris Snyder chris at psydeshow.org
Wed Feb 12 17:13:03 EST 2003


Jeremy Hise wrote:

>     function parse() {
>        // Get an array of items such as 'first_name', 'last_name', etc
>        $kws = $this->get_tags();
>
>        // If we do have an array of keywords
>        if(is_array($kws)) {
>            // For each keyword
>            foreach($kws as $kw) {
>                // Get the value from this object's data hasa
>                $value = $this->data["$kw"];  // <-- this has no data in it inside this loop
>                // Replace the smac tagged keyword with the value
>                $this->body = ereg_replace("<smac>".$kw."</smac>", $value, $this->body);
>            }
>        }
>        return($this->body);
>    }
>
>  
>
I'd focus on the array ($kws) actually returned by $this->get_tags().
It seems like your code would only work if the $kws array had keys named 
after your keywords, and not values named after them. In other words, 
make sure

foreach( $kws as $key=>$value ) {
    print "$key=>$value";
    }

isn't saying something like:

0=>first_name
1=>email

etc.

    chris.

-- 
HIP HOP CLOWN MONTH
booth of the day: all day, every day
http://hiphopclown.org/berylium/showcase/





More information about the talk mailing list