fork download
  1. <?php
  2.  
  3. function wrapWithUnion(array $params)
  4. {
  5. if (is_null($params[0])) {
  6. return "'{$params[1]}'";
  7. }
  8.  
  9. return "ST_Union({$params[0]},'{$params[1]}')";
  10. }
  11.  
  12. $arr = array("eee","fff","ggg","hhh");
  13.  
  14. $result = null;
  15.  
  16. foreach ($arr as $val) {
  17. $result = wrapWithUnion(array($result, $val));
  18. }
  19.  
  20. var_dump($result);
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
string(53) "ST_Union(ST_Union(ST_Union('eee','fff'),'ggg'),'hhh')"