Python’s urlparse.urljoin equivalent in PHP

I’ve searched the web carefully and found nothing but spam while looking for the equivalent of python’s urlparse.urljoin for PHP so I have decided to write my own function for this purpose. After I was finished writing it and tested it a bit, I was so happy with the result that I decided to share the function:

function urljoin( $url1, $url2 ) {
	$p1 = parse_url( $url1 );
	$p2 = parse_url( $url2 );
	$r = array_merge( $p1, $p2 );
	$spc = array( 'query', 'fragment', 'path' );
	foreach( $p1 as $k => $v )
		if( !isset( $p2[ $k ] ) && in_array( $k, $spc ) )
			unset( $r[ $k ] );
	if( isset( $r['path'] ) && !isset( $p2['host'] ) ) {
		if( strpos( $url2, '/' ) !== 0 ) {
			$path1 = explode( '/', isset( $p1['path'] ) ? $p1['path'] : '' );
			$path2 = explode( '/', isset( $p2['path'] ) ? $p2['path'] : '' );
			array_pop( $path1 );
			foreach( $path2 as $px ) {
				switch( $px ) {
					case '..':
						array_pop( $path1 );
					case '.':
						# nothing
						$path1[] = $px;
			$r['path'] = implode( '/', $path1 );
	$out = ( isset( $r['scheme'] ) ? $r['scheme'] . '://' : 'http://' ) .
		( isset( $r['user'] ) ? $r['user'] . ( isset( $r['pass'] ) ? ':' . $r['pass'] : '' ) . '@' : '' ) .
		$r['host'] . ( isset( $r['port'] ) ? ':' . $r['port'] : '' ) . '/' .
		ltrim( ( isset( $r['path'] ) ? $r['path'] : '' ), '/' ) .
		( isset( $r['query'] ) ? '?' . $r['query'] : '' ) .
		( isset( $r['fragment'] ) ? '#' . $r['fragment'] : '' );
	return $out;

Happy coding :D


Little Printer. The coolest printer around!

I’ve got this today in my email account and i was so amazed of how cool and handy this thing looks.

Little Printer

Little Printer

“Little Printer lives in your home, bringing you news, puzzles and gossip from friends. Use your smartphone to set up subscriptions and Little Printer will gather them together to create a timely, beautiful mini-newspaper.”

You can pull out great news titles and puzzles that you can take with you and read on a little piece of paper instead of your smart phone.




Here is a video presentation:


Google Maps to Charge for Usage

Google Maps

Google Map link users will now be charged for high usage. From January 2012 the search engine giant will charge for Google Maps API service after the limit of 25,000 “hits” crosses in a single day.

Google Maps links is mostly used by travel related websites to provide link to the customers to view the destination inquired about. It is rumored that Google will charge $4 for every excess 1,000 views.

The high limit of 25,000 free hits are maintained by Google before charging “will only affect 0.35% of users.”

Read More


Adobe stops development on mobile browser Flash

Adobe Systems Inc. is pulling its Flash software for Web video and games from the browsers of mobile devices, though Flash will still work on mobile apps and on the Web browsers of regular computers.

The move is a win for Apple Inc., which has famously banned Flash from working on the iPhone and the iPad. Adobe said Wednesday, however, that the about-face is about giving people what they want.

Adobe is now focusing their development efforts on:

  • Applications for mobile
  • Expressive content on the desktop (in and out of browser)
  • Increasing their investments in HTML5 in general
Read more here

Themes Masters – Our new addition. (free themes)

Hello Guys.

We just launched a new website called Themes Masters. Right now is a simple one page website with a gallery of stuff we offer for free. If you are interested go ahead and check it out. Depending on the interest we see from you guys we will get this website bigger.

Also if you are a designer but you lack in code skills we have a proposition for a collaboration with you so just go on there and leave us 2 lines or email us at:

Down here are 2 themes you can download for free. One is a PSD template and another one is a HTML template:

Simple Blog - HTML template

Simple Blog - HTML template

Light My Way - PSD template

Light My Way - PSD template

We’ll keep you posted with new stuff we come up with here on the blog too so if you have any suggestions don’t hesitate to leave us a comment we will respond for sure. Website

Themes Masters - Website

Themes Masters - Website


Agent8Ball – HTML5 Canvas Experiment

This is one of the greatest canvas works i’ve seen in a while.

It’s a game with a simple mission: “The international Billiards Tournament is being infiltrated by the terrorist organization CHALK. Do not let them win! Sink as many balls as possible before the timer runs out.

Check it out very entertaining and it works great on Chrome ;)