ID: 39340 User updated by: thehub at lofty dot net dot au Reported By: thehub at lofty dot net dot au Status: Open Bug Type: Feature/Change Request Operating System: Windows XP PHP Version: 4.4.4 New Comment:
or perhaps for a long piece of code that would be used a lot. this ugly rectangle of code for example: $server[$currServ][$currDB][$currGroup][$currUser]['access']=4; $server[$currServ][$currDB][$currGroup][$currUser]['email']=''; $server[$currServ][$currDB][$currGroup][$currUser]['lastlogin']=0; $server[$currServ][$currDB][$currGroup][$currUser]['projects']=array(); becomes with($server[$currServ][$currDB][$currGroup][$currUser]){ $['access']=4; $['email']=''; $['lastlogin']=0; $['projects']=array() } kind of like a function that's created on the fly and then destroyed when it's finished Previous Comments: ------------------------------------------------------------------------ [2006-11-02 02:34:22] thehub at lofty dot net dot au Description: ------------ Visual Basic has a neat little code trick that I'd like to see in PHP... With object1 .property1="value" .function1() End With And it can be nested. This is useful if you don't want to create a variable to hold the return of, e.g. a function call that returns an array, when you only need it for two or three lines. Reproduce code: --------------- with($nested_array['a_very_long_key']){ $[0]='apples'; with(function1($[1]->data)) echo template($['title'],$['content']); } // or with $object1: with $->property1: function1($['key_of_property1']); endwith endwith ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39340&edit=1