Gossamer Forum
Home : Products : Gossamer Links : PHP Front End :

Conver this perl to php?

Quote Reply
Conver this perl to php?
Hiya,

Can anyone tell me how to conver this perl into php code?

Code:
foreach (keys %$ATTRIBS) {
$self->{$_} = ref $ATTRIBS->{$_} eq 'HASH'
? {%{$ATTRIBS->{$_}}}
: $ATTRIBS->{$_};
}

The $ATTRIBS hash above would be an array in php, which could also contain other arrays as the values.

getting slightly confused with myself...
regan

Last edited by:

ryel01: Nov 8, 2005, 6:16 PM
Quote Reply
Re: [ryel01] Conver this perl to php? In reply to
This is what I've got in php - it shows what I'm trying to do...

Code:
foreach ( $ATTRIBS as $key ) {
$this->$key = is_array($ATTRIBS['$key'])
? **ASSIGN THE VALUE AS AN ARRY** ATTRIBS['$key']
: $ATTRIBS['$key'];
}

Problems I can't figure out...

1. $this->$key doesn't assign the name of $key as the object property name.

2. ? ATTRIBS['$key'] has an array for the value, so what i want to do is pass that array to the object property so that $this->$key then is the same array.

Hope that clears the question up a bit.

Can anyone help?

Regan.
Quote Reply
Re: [ryel01] Conver this perl to php? In reply to
figured it out.


Code:
foreach ( $ATTRIBS as $key => $value) {
$this->$key = is_array($value) ? eval( 'return $value ;') : $value ;
}