<?php function arrayOfAllFields( $mask, $tableName){ $loop = 0; $result = describe( $tableName); $string = '$this->table = Array( '."\n"; $loop.' => '. ( $string[strlen($string)-1] != ' ') ? ( ', ') : ( null).( strcasecmp( $mask, 'Comment')) ? (''Comment' => ''.$table['Comment'].'' ') : ( null). ')'; $loop++; } $string = $string."\n". ' );'; return $string; } ?>
No i wydawało mi się że będzie chodzić, ale produkt tej funkcji był taki:
<?php 'Comment' => 'hidden' ); ?>
Szukałem błędu, nie znalazłem, parser Eclipsa teżżadnego nie znajdował. Pomyślałem że to przez wstawienie "null" w operatorach trójargumentowych, ale zamiana ich na "' '", albo na "'a'" nic nie dała, nie wiedziałem o co chodzi, więc poświęciłem czytelność kodu i zrobiłem to samo tyle że na IF'ach:
<?php function arrayOfAllFields( $mask, $tableName){ $loop = 0; $result = describe( $tableName); $string = '$this->table = Array( '."\n"; $string = $string.$loop.' => '.' Array ( '; $string = $string.')'; $loop++; } $string = $string."\n". ' );'; return $string; } ?>
No i chodzi jak złoto:
<?php ); ?>
tylko nie rozumiem dlaczego tak jest, czy ktoś może mi to wytłumaczyć, albo powiedzieć jak zrobić zeby to samo działało na operatorach trójargumentowych?
Nie wiem czy to potrzebne, ale zamieszczę kod funkcji describe
<?php function describe( $tableName){ $query = 'SHOW FULL FIELDS FROM `'.$tableName.'` FROM `sphere`;'; return $result; } ?>