[PHP] Removing duplicate in an array… really fast

Let’s imagine you have a huge array, with say couple ten thousands of elements and you want to remove any duplicates entries in this array. As PHP programmer you’ll be thinking of array_unique. For a “small” sized array and one dimensional array this one does the trick.

I have some nice snippets which cover multi dimensional and/or huge sized array.

First: you have a huge, one dimensional array.

This one works only on one dimensional array. The key of the last element will be preserved and the keys are not sorted

Second: for a huge, multi dimensional array


  1. http://dk.php.net/manual/en/function.array-unique.php#97285
  2. http://www.puremango.co.uk/2010/06/fast-php-array_unique-for-removing-duplicates/

[TYPO3] Redirect to last page

Problem of the week:

you have a password protected pages on your TYPO3 site. If you spread the URL of the pages and other user will be shown the login page, if they call the URL. Problem will be, after logging in, the user is not redirected to the last page, which they call.

The felogin extension of TYPO3 supports 6 type of redirect after login:

  1. defined by usergroup record
  2. defined by user record
  3. TypoScript or Flexform of the felogin extension
  4. GET/POST-Parameter
  5. Referer
  6. Domain entries

The solution is the “referer” redirection. The question is how. This is where we use the fabulous TypoScript.

This TypoScript creates a redirect per meta tag (see wrap), but to which URL. The magic happens in the typolink function. xxx is your login page. The GET parameter “referer” will have the value of the last page, which the user visited.

The magic does not end here. You have to set to “referer” redirect in the flexform of the felogin extension.


so that’s all.. hope this could be help.




Wrapping image based on width… pure TypoScript

following issue: images should be wrapped with various class parameter (or div, or whatever) based on its width. And it should be solved only per TypoScript…

hmmm… quite a difficult one, don’t you think? well, you know what… I solved it… 😀

Continue reading Wrapping image based on width… pure TypoScript

Rewrite robots.txt

Your CMS (read: TYPO3) can handle multiple subdomain in one installation. Problem: you can only put one robots.txt in the htdocs. The following rewrite rule will solve the problemby rewriting robots.txt to robots_(subdomain).txt

it will do following rewrite:

  • www.domain.tld/robots.txt will load robots_www.txt
  • sub1.domain.tld/robots.txt will load robots_sub1.txt, if it’s not exist, then robots_def.txt will be loaded