Contact Dylan Jones

x Cancel
posted 1 year ago

PHP Function generating comma separated lists

                function comma_separate ($input, $joiner = 'and') {
	$input = array_unique($input);
	$output = $input[0];
	if(count($input)==1)
		return $output;
	for($a=1;$a<(count($input)-1);$a++)
		$output .= ', '.$input[$a];
	$output .= ' '.$joiner.' '.$input[count($input)-1];
	return $output;
}                
Raw

A snippet of PHP to share with you to that creates comma separated lists. This function takes an array of elements and a final joining word such as 'and' or 'or', and returns a string.

posted 2 years ago

Example use of the HTML5 History API

                		$('.item').click(function(e) {
			e.preventDefault();
			var id = $(this).attr('id');
			var title = $(this).attr('title');
			$('.tour').hide();
			$('#tour-'+id).show();
			$('.nav-item').css('background-color','#005000');
			$('nav #'+id).css('background-color','#4D924D');
			if(typeof history.pushState != 'undefined')
				history.pushState(id,'ybsolo | Tour | '+title,'http://ybsolo.com/tour/'+id);
			return false;
		});                
Raw

I have used the upcoming History API to show different content that is associated with a unique URL on a tour page. As you go through the tour, the content is changed through JavaScript and the URL is updated without actually re-loading the page saving time and server resources. The full example can be seen at ybsolo.com/tour/

I have tested it in the latest Chrome and Firefox browsers.

posted 2 years ago

Google Webmaster Tools - Soft 404 Errors

I am not a fan of errors so how can I avoid getting these soft 404 errors on my sites?

posted 2 years ago

Text to Speech through Google Translator

http://translate.google.com/translate_tts?tl=en&q=HELLO

I use this as a simple text-to-speech engine. Put any text as the query (q=SOME TEXT) and it converts it to MP3. Thanks Google!