On Wed, 2003-12-10 at 03:01, jason davidson wrote:
> Ive seen the Control Flow constuct With ...End With used in VB (yup, 
> VB.. :)) although im not a fan of VB, i liked the feature, is there any 
> consideration to this kind of construct for php.
> here the only example if it i could find online for anyone that hasnt 
> seen it before.
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcn7/html/vaconusingwith.asp
> Aside from being VB, is there anything wrong with it.
> 
> Jason

As for me - i would solve it with PHP without changing the langauge
in the following way:

> Sub MyInput()
>    With Workbooks("Book1").Worksheets("Sheet1").Cells(1, 1)
>       .Formula = "=SQRT(50)"
>       With .Font
>          .Name = "Arial"
>          .Bold = True
>           .Size = 8
>       End With
>    End With
> End Sub

would produce somthing like:
function my_input() {
 global $workbooks;
  $chg=array('formula'=>'sqrt(50)',
  'font'=>array('name'=>'Arial','bold'=>true,'size'=>8)):
 join_properties($workbooks['book1'].workshhets['sheet1'].cells[1][1],$chg)
}


Here is working(not heavily tested though) example
that shows the general idea:

<?php
    header("Content-type: text/plain\n");
    $v=array('xxx'=>1,'yyy'=>array('y1'=>7,'y2'=>8));
    print_r($v);
    echo "\n";
                                                                                
    function update_props_recursively(&$srcdst,$updater) {
        foreach($updater as $k=>$v) {
            if(is_scalar($srcdst[$k])) {
                $srcdst[$k]=$updater[$k];
            } else {
                update_props_recursively($srcdst[$k],$updater[$k]);
            }
        }
    }
                                                                                
    $chg=array('xxx'=>2,'yyy'=>array('y2'=>99));
    update_props_recursively($v,$chg);
    print_r($v);
?>



--------------------------------------------------------
FREE 10MB email + Antivirus + AntiSpam + POP3 + more....
Get it at http://www.doal.co.il:81/free/?c=both

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to