From yitzchak.schaffer at gmx.com Thu Oct 21 17:13:55 2010 From: yitzchak.schaffer at gmx.com (Yitzchak Schaffer) Date: Thu, 21 Oct 2010 17:13:55 -0400 Subject: [nycphp-talk] phpDoc and versioning Message-ID: <4CC0AD13.1020608@gmx.com> Hello all, I am working on an OSS project. We are moving to our next version, and it's time to increment the version number in our phpDoc. Every time this comes up, I have to dust off my awk, etc. Is anyone aware of automated, e.g. IDE-based solutions for this? We use Netbeans. Many thanks, -- Yitzchak Schaffer Systems Manager Touro College Libraries (212) 463-0400 x5230 http://www.tourolib.org/ Access Problems? Contact systems.library at touro.edu From ps at blu-studio.com Thu Oct 21 22:26:57 2010 From: ps at blu-studio.com (Peter Sawczynec) Date: Thu, 21 Oct 2010 22:26:57 -0400 Subject: [nycphp-talk] Array-cersize Message-ID: <011801cb7190$9a6a7b10$cf3f7130$@com> As always I thank everyone in advance for their assistance. There can be any number of b_array's in array $arr_countable_items. $arr_countable_items = array ( b_array(key1=value1, key2=value2, key3=value3), b_array(key1=value1, key2=value2, key3=value3) .... ); What is the proper best way for me to count how many (if any) b_arrays are in $arr_countable_items. Further, what is the best way to count how many value1s (if any) are in $arr_countable_items. $arr_countable_items_2 = array ( b_array( c_array(key1=value1, key2=value2), c_array(key1=value1, key2=value2) ), b_array( c_array(key1=value1, key2=value2), c_array(key1=value1, key2=value2) ) .... ); What is the best way to count how many value1s (if any) are in $arr_countable_items_2. Warmest regards, Peter Sawczynec Technology Dir. bl?studio 941.893.0396 ps at blu-studio.com www.blu-studio.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From ramons at gmx.net Fri Oct 22 07:24:18 2010 From: ramons at gmx.net (David Krings) Date: Fri, 22 Oct 2010 07:24:18 -0400 Subject: [nycphp-talk] Array-cersize In-Reply-To: <011801cb7190$9a6a7b10$cf3f7130$@com> References: <011801cb7190$9a6a7b10$cf3f7130$@com> Message-ID: <4CC17462.9070103@gmx.net> On 10/21/2010 22:26, Peter Sawczynec wrote: > What is the proper best way for me to count how many (if any) b_arrays are in > $arr_countable_items. > > What is the best way to count how many value1s (if any) are in > $arr_countable_items_2. Hi! Doesn't count() do what you need to do? Without paramter it gives you the count of the elements in the array, with the parameter COUNT_RECURSIVE it will give you the count including the sub-arrays. See here: http://www.php.net/manual/en/function.count.php David From ps at blu-studio.com Fri Oct 22 11:03:06 2010 From: ps at blu-studio.com (ps at blu-studio.com) Date: Fri, 22 Oct 2010 08:03:06 -0700 Subject: [nycphp-talk] Array-cersize Message-ID: <20101022080306.69a71d519390b8693ef02edaf26f7b19.0daa089fd8.wbe@email00.secureserver.net> An HTML attachment was scrubbed... URL: From glenn310b at mac.com Fri Oct 22 14:22:31 2010 From: glenn310b at mac.com (Glenn) Date: Fri, 22 Oct 2010 14:22:31 -0400 Subject: [nycphp-talk] Array-cersize In-Reply-To: <011801cb7190$9a6a7b10$cf3f7130$@com> References: <011801cb7190$9a6a7b10$cf3f7130$@com> Message-ID: I'm not sure that I fully understand the subtleties of the data/ problem but... array_walk_recursive might be part of a solution. You could write a callback function to use with it to do whatever you need. http://www.php.net/manual/en/function.array-walk-recursive.php hth, glenn On Oct 21, 2010, at 10:26 PM, Peter Sawczynec wrote: > As always I thank everyone in advance for their assistance. > > There can be any number of b_array's in array $arr_countable_items. > > $arr_countable_items = > array > ( > b_array(key1=value1, key2=value2, key3=value3), > b_array(key1=value1, key2=value2, key3=value3) > .... > ); > What is the proper best way for me to count how many (if any) > b_arrays are in $arr_countable_items. > Further, what is the best way to count how many value1s (if any) are > in $arr_countable_items. > > $arr_countable_items_2 = > array > ( > b_array( c_array(key1=value1, key2=value2), > c_array(key1=value1, key2=value2) ), > b_array( c_array(key1=value1, key2=value2), > c_array(key1=value1, key2=value2) ) > .... > ); > What is the best way to count how many value1s (if any) are in > $arr_countable_items_2. > > Warmest regards, > > Peter Sawczynec > Technology Dir. > bl?studio > 941.893.0396 > ps at blu-studio.com > www.blu-studio.com > > _______________________________________________ > New York PHP Users Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/Show-Participation -------------- next part -------------- An HTML attachment was scrubbed... URL: From paul at devonianfarm.com Fri Oct 22 14:50:59 2010 From: paul at devonianfarm.com (Paul A Houle) Date: Fri, 22 Oct 2010 14:50:59 -0400 Subject: [nycphp-talk] Squashing accented characters Message-ID: <4CC1DD13.5030003@devonianfarm.com> For my site at http://ookaboo.com/ I'm running into the problem that people are searching for "Dusseldorf" but the name of the place is "D?sseldorf", so they don't find it. It seems to me a good answer to this is to have some function that squashes accented characters down to unaccented forms. I'd index the unaccented forms and also squash down queries so they'd always match up. I definitely need to do both ISO-Latin-1 and the Latin-Extended-A, because fate has given me a lot of place names that have the Polish dark L in them (? ). It also seems like there are a lot of characters in Latin Extended-B that would also map plausably to unaccented characters. I can see how to write something like this, I'd need to parse out the Unicode code points from UTF-8 and run them through a lookup table, but it's a lot of details and I wonder if anybody has written a PHP function to do this already. -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew at plexpod.com Fri Oct 22 14:57:53 2010 From: andrew at plexpod.com (Andrew Yochum) Date: Fri, 22 Oct 2010 14:57:53 -0400 Subject: [nycphp-talk] Squashing accented characters In-Reply-To: <4CC1DD13.5030003@devonianfarm.com> References: <4CC1DD13.5030003@devonianfarm.com> Message-ID: <4CC1DEB1.2040609@plexpod.com> Hi Paul, You can achieve that with unicode transliteration: http://cldr.unicode.org/index/cldr-spec/transliteration-guidelines Check out the PHP Iconv extension: http://us.php.net/manual/en/intro.iconv.php Hope that helps! Regards, Andrew On 10/22/10 2:50 PM, Paul A Houle wrote: > For my site at > > http://ookaboo.com/ > > I'm running into the problem that people are searching for > "Dusseldorf" but the name of the place is "D?sseldorf", so they don't > find it. > > It seems to me a good answer to this is to have some function that > squashes accented characters down to unaccented forms. I'd index the > unaccented forms and also squash down queries so they'd always match > up. I definitely need to do both ISO-Latin-1 and the > Latin-Extended-A, because fate has given me a lot of place names > that have the Polish dark L in them (? > ). It also seems like > there are a lot of characters in Latin Extended-B that would also map > plausably to unaccented characters. > > I can see how to write something like this, I'd need to parse out the > Unicode code points from UTF-8 and run them through a lookup table, > but it's a lot of details and I wonder if anybody has written a PHP > function to do this already. > > > _______________________________________________ > New York PHP Users Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/Show-Participation -- Andrew Yochum Plexpod andrew at plexpod.com office: 718-360-0879 mobile: 347-688-4699 fax: 718-504-6289 -------------- next part -------------- An HTML attachment was scrubbed... URL: From rmarscher at beaffinitive.com Fri Oct 22 15:02:58 2010 From: rmarscher at beaffinitive.com (Rob Marscher) Date: Fri, 22 Oct 2010 15:02:58 -0400 Subject: [nycphp-talk] Squashing accented characters In-Reply-To: <4CC1DD13.5030003@devonianfarm.com> References: <4CC1DD13.5030003@devonianfarm.com> Message-ID: On Oct 22, 2010, at 2:50 PM, Paul A Houle wrote: > I'm running into the problem that people are searching for "Dusseldorf" but the name of the place is "D?sseldorf", so they don't find it. I haven't seen a php function to do it (not to say one doesn't exist). However, I use sphinx for search and there's a unicode to latin post in their wiki that might help you: http://sphinxsearch.com/wiki/doku.php?id=charset_tables#slovak With a related post here - http://darwinweb.net/articles/thinking-sphinx-case-folding-configuration I'm not exactly sure if those translations are baked into sphinx now. See http://sphinxsearch.com/docs/manual-1.10.html#charsets Perhaps switching to using sphinx search could make things easier for you? http://sphinxsearch.com/downloads.html -Rob -------------- next part -------------- An HTML attachment was scrubbed... URL: From ramons at gmx.net Fri Oct 22 16:33:57 2010 From: ramons at gmx.net (David Krings) Date: Fri, 22 Oct 2010 16:33:57 -0400 Subject: [nycphp-talk] Squashing accented characters In-Reply-To: <4CC1DD13.5030003@devonianfarm.com> References: <4CC1DD13.5030003@devonianfarm.com> Message-ID: <4CC1F535.1070307@gmx.net> On 10/22/2010 14:50, Paul A Houle wrote: > I'm running into the problem that people are searching for "Dusseldorf" but > the name of the place is "D?sseldorf", so they don't find it. That is very unfortunate, because that is the city I was born in. As for your problem, I got nothing. David From edwardpotter at gmail.com Fri Oct 22 16:45:44 2010 From: edwardpotter at gmail.com (Edward Potter) Date: Fri, 22 Oct 2010 16:45:44 -0400 Subject: [nycphp-talk] Squashing accented characters In-Reply-To: <4CC1F535.1070307@gmx.net> References: <4CC1DD13.5030003@devonianfarm.com> <4CC1F535.1070307@gmx.net> Message-ID: Yes, something that seems VERY simple can get VERY complicated, VERY fast! Friend did this site, he has put in a zillion hours figuring out all the characters issues. one of the rockstar coders (dreams in vi), and still he says, learning something new everyday. :-))) http://dreamtype.com/ "You mean you don't know the Swahili character site? You have to know that!" I'm like what? Swahili? :-))))) (and yes, I did not solve your problem either!) sorry! On Fri, Oct 22, 2010 at 4:33 PM, David Krings wrote: > On 10/22/2010 14:50, Paul A Houle wrote: >> >> I'm running into the problem that people are searching for "Dusseldorf" >> but >> the name of the place is "D?sseldorf", so they don't find it. > > That is very unfortunate, because that is the city I was born in. As for > your problem, I got nothing. > > David > _______________________________________________ > New York PHP Users Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/Show-Participation > -- IM/iChat: ejpusa Links: http://del.icio.us/ejpusa Follow me: http://www.twitter.com/ejpusa Karma: http://www.coderswithconscience.com From mitch.pirtle at gmail.com Sat Oct 23 11:37:10 2010 From: mitch.pirtle at gmail.com (Mitch Pirtle) Date: Sat, 23 Oct 2010 11:37:10 -0400 Subject: [nycphp-talk] phpDoc and versioning In-Reply-To: <4CC0AD13.1020608@gmx.com> References: <4CC0AD13.1020608@gmx.com> Message-ID: On Thu, Oct 21, 2010 at 5:13 PM, Yitzchak Schaffer wrote: > Hello all, > > I am working on an OSS project. We are moving to our next version, and it's > time to increment the version number in our phpDoc. > > Every time this comes up, I have to dust off my awk, etc. Is anyone aware of > automated, e.g. IDE-based solutions for this? We use Netbeans. You could always use svn keyword expansion - or look for a git equivalent (if there is one). Then your svn export will always spit out the correct version number. -- Mitch From jcampbell1 at gmail.com Sun Oct 24 13:24:31 2010 From: jcampbell1 at gmail.com (John Campbell) Date: Mon, 25 Oct 2010 01:24:31 +0800 Subject: [nycphp-talk] Squashing accented characters In-Reply-To: <4CC1DD13.5030003@devonianfarm.com> References: <4CC1DD13.5030003@devonianfarm.com> Message-ID: I use a regex, and apply it to the source and the indexed text. it is pretty simple like: preg_replace('/[??????]/iu','a',$x); preg_replace('/[????]/iu','e',$x) It is a bit of a hack, but works quite well in practice. If you do some googling, you can find many regex variations that will do what you want. Some get pretty involved such as handling ligatures (*? -> ss)* On Sat, Oct 23, 2010 at 2:50 AM, Paul A Houle wrote: > For my site at > > http://ookaboo.com/ > > I'm running into the problem that people are searching for "Dusseldorf" but > the name of the place is "D?sseldorf", so they don't find it. > > It seems to me a good answer to this is to have some function that squashes > accented characters down to unaccented forms. I'd index the unaccented > forms and also squash down queries so they'd always match up. I definitely > need to do both ISO-Latin-1 and the Latin-Extended-A, because fate has > given me a lot of place names that have the Polish dark L in them (?). > It also seems like there are a lot of characters in Latin Extended-B that > would also map plausably to unaccented characters. > > I can see how to write something like this, I'd need to parse out the > Unicode code points from UTF-8 and run them through a lookup table, but > it's a lot of details and I wonder if anybody has written a PHP function to > do this already. > > _______________________________________________ > New York PHP Users Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/Show-Participation > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chsnyder at gmail.com Mon Oct 25 07:37:32 2010 From: chsnyder at gmail.com (Chris Snyder) Date: Mon, 25 Oct 2010 07:37:32 -0400 Subject: [nycphp-talk] Squashing accented characters In-Reply-To: <4CC1DEB1.2040609@plexpod.com> References: <4CC1DD13.5030003@devonianfarm.com> <4CC1DEB1.2040609@plexpod.com> Message-ID: On Fri, Oct 22, 2010 at 2:57 PM, Andrew Yochum wrote: > Hi Paul, > > You can achieve that with unicode transliteration: > ??? http://cldr.unicode.org/index/cldr-spec/transliteration-guidelines > Check out the PHP Iconv extension: > ??? http://us.php.net/manual/en/intro.iconv.php > > Hope that helps! An example would rock this thread, Andrew. Transliteration is non-obvious. From the GNU iconv page: "It has also some limited support for transliteration, i.e. when a character cannot be represented in the target character set, it can be approximated through one or several similarly looking characters. Transliteration is activated when "//TRANSLIT" is appended to the target encoding name. " So you would need to pre-convert all of your searchable terms into ISO-8859-1/TRANSLIT ? From anthony at dating2p0.com Mon Oct 25 11:28:55 2010 From: anthony at dating2p0.com (Anthony Wlodarski) Date: Mon, 25 Oct 2010 11:28:55 -0400 (EDT) Subject: [nycphp-talk] Solr client libraries. Message-ID: <1288020535.782216792@192.168.2.230> Hello everyone, Currently I am developing with the Solr library found here: http://code.google.com/p/solr-php-client/. It is a full featured library and so far I am enjoying how the libraries have been built (easy drop in for zend framework thanks to the naming conventions. I don't think I will be changing libraries but it is also good to know what else is out there. What are you using to interface with Sorl and why do you like it? Regards, Anthony Wlodarski Lead Software Engineer get2know.me 646 285 0500 x217 anthony at get2know.me -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcech at phpwerx.net Mon Oct 25 11:46:18 2010 From: dcech at phpwerx.net (Dan Cech) Date: Mon, 25 Oct 2010 11:46:18 -0400 Subject: [nycphp-talk] Solr client libraries. In-Reply-To: <1288020535.782216792@192.168.2.230> References: <1288020535.782216792@192.168.2.230> Message-ID: <4CC5A64A.2030007@phpwerx.net> Anthony, > Currently I am developing with the Solr library found here: > http://code.google.com/p/solr-php-client/. It is a full featured > library and so far I am enjoying how the libraries have been built > (easy drop in for zend framework thanks to the naming conventions. I've had good luck with that lib, it's straightforward and gets the job done. Most other http code I use is based on cURL rather than file_get_contents and it would be nice to have that option if you're running without fopen url support. So far it hasn't been an issue but it would be simple to extend the service class and modify the utility methods it uses for http. > I don't think I will be changing libraries but it is also good to > know what else is out there. What are you using to interface with > Sorl and why do you like it? It supports everything I've needed so far, haven't messed around yet with some of the new features in the latest Solr but I'm guessing it'll handle those ok too. Bottom line, it's simple, lightweight and works. Dan From david at davidmintz.org Mon Oct 25 12:22:08 2010 From: david at davidmintz.org (David Mintz) Date: Mon, 25 Oct 2010 12:22:08 -0400 Subject: [nycphp-talk] empty($array['foo']) versus array_key_exists('foo', $array) Message-ID: Anybody know of any reason not to save a little typing with empty($array['foo']) -- David Mintz http://davidmintz.org/ It ain't over: http://www.healthcare-now.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From dcech at phpwerx.net Mon Oct 25 12:25:57 2010 From: dcech at phpwerx.net (Dan Cech) Date: Mon, 25 Oct 2010 12:25:57 -0400 Subject: [nycphp-talk] empty($array['foo']) versus array_key_exists('foo', $array) In-Reply-To: References: Message-ID: <4CC5AF95.4010501@phpwerx.net> On 10/25/2010 12:22 PM, David Mintz wrote: > Anybody know of any reason not to save a little typing with > > empty($array['foo']) They're different comparisons, array_key_exists will return true if there is an element with that key *even if it is null or some other empty() value* (and the logic is reversed, you need !empty()), isset($array['foo']) is closer but will return false if the value is null. http://us3.php.net/manual/en/types.comparisons.php Dan From david at davidmintz.org Mon Oct 25 12:32:18 2010 From: david at davidmintz.org (David Mintz) Date: Mon, 25 Oct 2010 12:32:18 -0400 Subject: [nycphp-talk] empty($array['foo']) versus array_key_exists('foo', $array) In-Reply-To: <4CC5AF95.4010501@phpwerx.net> References: <4CC5AF95.4010501@phpwerx.net> Message-ID: On Mon, Oct 25, 2010 at 12:25 PM, Dan Cech wrote: > On 10/25/2010 12:22 PM, David Mintz wrote: > >> Anybody know of any reason not to save a little typing with >> >> empty($array['foo']) >> > > They're different comparisons, array_key_exists will return true if there > is an element with that key *even if it is null or some other empty() value* > (and the logic is reversed, you need !empty()), isset($array['foo']) is > closer but will return false if the value is null. > > http://us3.php.net/manual/en/types.comparisons.php > > Ah yes, of course. I might have added that for what I have in mind, if $array['foo'] existed and were any empty() value, that would serve my purposes just as well. Here's a deep insight: array_key_exists is nice for finding out if the array key exists. Thanks. -- David Mintz http://davidmintz.org/ It ain't over: http://www.healthcare-now.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew at plexpod.com Mon Oct 25 12:35:00 2010 From: andrew at plexpod.com (Andrew Yochum) Date: Mon, 25 Oct 2010 12:35:00 -0400 Subject: [nycphp-talk] Squashing accented characters In-Reply-To: References: <4CC1DD13.5030003@devonianfarm.com> <4CC1DEB1.2040609@plexpod.com> Message-ID: <4CC5B1B4.9080003@plexpod.com> On 10/25/10 7:37 AM, Chris Snyder wrote: > On Fri, Oct 22, 2010 at 2:57 PM, Andrew Yochum wrote: >> Hi Paul, >> >> You can achieve that with unicode transliteration: >> http://cldr.unicode.org/index/cldr-spec/transliteration-guidelines >> Check out the PHP Iconv extension: >> http://us.php.net/manual/en/intro.iconv.php >> >> Hope that helps! > An example would rock this thread, Andrew. Sure. I'll admit, its finicky and convoluted. PHP 5.3 has an new Internationalization extension, but I've yet to play with it and IIRC, it does not have transliteration yet. http://php.net/intl Andrei Zmievski demoed translitteration in PHP 6 in 2006, but well, thats another story. http://zmievski.org/talks/ So, thus, the Iconv solution is still the answer. Output: Original : Some unicode character text: ????? ???? D?sseldorf TRANSLIT : Some unicode character text: aaeaaaa eeee Duesseldorf IGNORE : Plain : Some unicode character text: YMMV. Also, Derrick Rethans has a cool little PECL extension that does transliteration quite simply. Never used it, but looks good. http://derickrethans.nl/projects.html#translit Hope that helps... more. Regards, Andrew -- Andrew Yochum Plexpod andrew at plexpod.com office: 718-360-0879 mobile: 347-688-4699 fax: 718-504-6289 From allen at TwoMiceAndAStrawberry.com Mon Oct 25 13:01:11 2010 From: allen at TwoMiceAndAStrawberry.com (Allen Shaw) Date: Mon, 25 Oct 2010 12:01:11 -0500 Subject: [nycphp-talk] empty($array['foo']) versus array_key_exists('foo', $array) In-Reply-To: References: <4CC5AF95.4010501@phpwerx.net> Message-ID: <4CC5B7D7.2040807@TwoMiceAndAStrawberry.com> On 10/25/2010 11:32 AM, David Mintz wrote: > Here's a deep insight: array_key_exists is nice for finding out if > the array key exists. Yeah, that's called RTFF. :-) -Shaw From paul at devonianfarm.com Mon Oct 25 13:03:12 2010 From: paul at devonianfarm.com (Paul A Houle) Date: Mon, 25 Oct 2010 13:03:12 -0400 Subject: [nycphp-talk] empty($array['foo']) versus array_key_exists('foo', $array) In-Reply-To: References: Message-ID: <4CC5B850.80905@devonianfarm.com> On 10/25/2010 12:22 PM, David Mintz wrote: > Anybody know of any reason not to save a little typing with > > empty($array['foo']) > I think also this will throw an error or exception if you're running with E_STRICT, which you should. From rmarscher at beaffinitive.com Mon Oct 25 13:12:46 2010 From: rmarscher at beaffinitive.com (Rob Marscher) Date: Mon, 25 Oct 2010 13:12:46 -0400 Subject: [nycphp-talk] empty($array['foo']) versus array_key_exists('foo', $array) In-Reply-To: <4CC5B850.80905@devonianfarm.com> References: <4CC5B850.80905@devonianfarm.com> Message-ID: <97300C08-3B87-4221-B528-E536526849E9@beaffinitive.com> On Oct 25, 2010, at 1:03 PM, Paul A Houle wrote: > On 10/25/2010 12:22 PM, David Mintz wrote: >> Anybody know of any reason not to save a little typing with >> empty($array['foo']) > I think also this will throw an error or exception if you're running with E_STRICT, which you should. I thought so too, but I tested it this morning and it didn't seem to throw a notice. It must operate like isset. From paul at devonianfarm.com Mon Oct 25 13:14:02 2010 From: paul at devonianfarm.com (Paul A Houle) Date: Mon, 25 Oct 2010 13:14:02 -0400 Subject: [nycphp-talk] Anybody doing anything cool w/ the tokenizer? Message-ID: <4CC5BADA.6000908@devonianfarm.com> Anybody using this? http://php.net/manual/en/book.tokenizer.php For a while I was using an autoloader that uses this tokenizer to make a list what classes are in what file http://gen5.info/q/2009/01/09/an-awesome-autoloader-for-php/ I had the idea of trying to "dynamically profile" what the autoloader loads after running a few pages, then gather up those files into one big file, which APC ought to be able to cache. My first draft of this didn't work because, sometimes there would be a situation where class A would extends on class B, but class A would come earlier in the file. It seems like you can get away with this some of the time, but not all of the time. I've rewritten the autoloader so it now keeps track of the "A extends B" and "A implements B" relationships, and I'm planning to topological sort the classes so they get put together in the right order. Hopefully this will work, and let me have both the benefits of autoloading and APC. Anyway, in the middle of all this I came to the feeling that people aren't really using the power of the tokenizer. The code would be a little more complicated, but it ought to be possible to build something that extracts all the methods and properties of functions or even build something that can take functions apart and put them back together again, which would have all sorts of fun applications. From rmarscher at beaffinitive.com Mon Oct 25 13:27:42 2010 From: rmarscher at beaffinitive.com (Rob Marscher) Date: Mon, 25 Oct 2010 13:27:42 -0400 Subject: [nycphp-talk] Anybody doing anything cool w/ the tokenizer? In-Reply-To: <4CC5BADA.6000908@devonianfarm.com> References: <4CC5BADA.6000908@devonianfarm.com> Message-ID: <3AED5C35-3316-45B5-9238-1DA7004CD5CD@beaffinitive.com> On Oct 25, 2010, at 1:14 PM, Paul A Houle wrote: > Anybody using this? > http://php.net/manual/en/book.tokenizer.php I noticed the Lithium framework uses it to parse views. http://lithify.me/docs/lithium/template I also recently saw it while digging through PhpDocumentor code. > http://gen5.info/q/2009/01/09/an-awesome-autoloader-for-php/ Reminds me of an article I recently read by Zend Framework developer Matthew Weier O'Phinney. http://weierophinney.net/matthew/archives/245-Autoloading-Benchmarks.html I think the code he mentions for generating the classmap moved here: http://github.com/weierophinney/zf2/blob/autoloading/bin/classmap_generator.php From paul at devonianfarm.com Mon Oct 25 13:32:38 2010 From: paul at devonianfarm.com (Paul A Houle) Date: Mon, 25 Oct 2010 13:32:38 -0400 Subject: [nycphp-talk] empty($array['foo']) versus array_key_exists('foo', $array) In-Reply-To: <97300C08-3B87-4221-B528-E536526849E9@beaffinitive.com> References: <4CC5B850.80905@devonianfarm.com> <97300C08-3B87-4221-B528-E536526849E9@beaffinitive.com> Message-ID: <4CC5BF36.90402@devonianfarm.com> On 10/25/2010 1:12 PM, Rob Marscher wrote: > On Oct 25, 2010, at 1:03 PM, Paul A Houle wrote: >> On 10/25/2010 12:22 PM, David Mintz wrote: >>> Anybody know of any reason not to save a little typing with >>> empty($array['foo']) >> I think also this will throw an error or exception if you're running with E_STRICT, which you should. > I thought so too, but I tested it this morning and it didn't seem to throw a notice. It must operate like isset. > Well if you think array_key_exists($key,$array) is wack, you can write function has_key($array,$key) { return array_key_exists($key,$array); } personally I hate the reversal of order in array_key_exists as compared to $array[$key]. The only trouble is that this one more thing for the guy who maintains your code in the future to remember. From guilhermeblanco at gmail.com Mon Oct 25 15:01:36 2010 From: guilhermeblanco at gmail.com (guilhermeblanco at gmail.com) Date: Mon, 25 Oct 2010 17:01:36 -0200 Subject: [nycphp-talk] empty($array['foo']) versus array_key_exists('foo', $array) In-Reply-To: <4CC5BF36.90402@devonianfarm.com> References: <4CC5B850.80905@devonianfarm.com> <97300C08-3B87-4221-B528-E536526849E9@beaffinitive.com> <4CC5BF36.90402@devonianfarm.com> Message-ID: Hi, isset($array[$key]) is around 160% faster than array_key_exists($key, $array). That's one of the changes we've benchmarked in Doctrine 1 that we integrated into Doctrine 1.2. Of course there're some situations that you cannot trust isset() and you should still keep with array_key_exists. Cheers, On Mon, Oct 25, 2010 at 3:32 PM, Paul A Houle wrote: > ?On 10/25/2010 1:12 PM, Rob Marscher wrote: >> >> On Oct 25, 2010, at 1:03 PM, Paul A Houle wrote: >>> >>> On 10/25/2010 12:22 PM, David Mintz wrote: >>>> >>>> Anybody know of any reason not to save a little typing with >>>> empty($array['foo']) >>> >>> I think also this will throw an error or exception if you're running with >>> E_STRICT, ?which you should. >> >> I thought so too, but I tested it this morning and it didn't seem to throw >> a notice. ?It must operate like isset. >> > ? ?Well if you think array_key_exists($key,$array) is wack, ?you can write > > function has_key($array,$key) { > ? ?return array_key_exists($key,$array); > } > > ? ?personally I hate the reversal of order in array_key_exists as compared > to $array[$key]. ?The only trouble is that this one more thing for the guy > who maintains your code in the future to remember. > _______________________________________________ > New York PHP Users Group Community Talk Mailing List > http://lists.nyphp.org/mailman/listinfo/talk > > http://www.nyphp.org/Show-Participation > -- Guilherme Blanco Mobile: +55 (16) 9215-8480 MSN: guilhermeblanco at hotmail.com S?o Paulo - SP/Brazil