Watkins Web 3: Blog

Example of explode()

There are two things to remember here:

  1. The explode() function returns an array, where each element is a “piece” from the explosion. None of those elements will contain the explosion string itself. So if I explode on the colon character by writing explode(":", "here:are:four:words");, that will return an array of the four words themselves without any colons.
  2. If you want a particular element of an array, just access it using something like this: $the_third_element_of_array_name = $array_name[2]. The bracket syntax refers to a particular element in the array, so when you store it in a variable, it’s stored as a plain ol’ scalar variable, not an array.
// store a plain old sentence in $sentence
$sentence = "First half of the sentence, second half of the sentence.";
// explode $sentence into pieces wherever a comma appears, and store the (two) pieces that result as an array called $exploded_sentence
$exploded_sentence = explode(", " , $sentence);
// I just want the second piece of the explosion, so I'll access the second element of the array using $exploded_sentence[1] (remember, the first piece can be accessed with $exploded_sentence[0])
$second_half = $exploded_sentence[1];
// $second_half is a plain ol' scalar variable (not an array), so we can run IT through explode(). Let's do so by exploding on the space character: this will return as many pieces as there are words in the sentence
$second_half_exploded = explode(" ", $second_half);
// $second_half_exploded is of course an array, so if we want the first word, we just access it at $second_half_exploded[0]
$first_word_second_half = $second_half_exploded[0];
echo $first_word_second_half;

Exercise 11: Retrieving XML

Enjoy the magic of RSS, XML, and forms.

Exercise 11 Exercise 11 Solution View Solution

Wordcamp is April 21

Watkins is hosting the Nashville WordCamp on Saturday, April 21st. More info at http://2012.nashville.wordcamp.org

Steve Wilkison has 20 free tickets for students, but you need to email him ASAP if you want to go. The deadline for the free tickets is this Friday.

Read more on the Wordcamp site.

New Watkinswebdev.com setup

Hi everyone,

We found a solution, which is to migrate everyone to his/her own subdomain. So if your stuff was at http://watkinswebdev.com/jschmoe/ before, it’s now at http://jschmoe.watkinswebdev.com/ (and your blog is at http://jschmoe.watkinswebdev.com/blog/).

I’ve already migrated all your stuff to the new location(s), but there’s some work left to do. To get set up with the new arrangement, please do the following.

Change your Cyberduck bookmark

  1. Open Cyberduck and get to the “Bookmark view” screen (you may have to disconnect and click the “book” icon).
  2. Highlight your bookmark and click the pencil icon to edit it.
  3. Under More Options, change your Path from watkinswebdev.com/jschmoe to jschmoe.watkinswebdev.com.
  4. Save the bookmark: it may be easiest to close the panel and drag the whole bookmark icon to the desktop. Then throw away the old one from your flash drive and drag the new one into its place.

Fix your Wordpress settings

Home URL

Right now you’re probably seeing an Error 404 message at the address of your blog home page (http://jschmoe.watkinswebdev.com/blog/). We need to tell Wordpress where the new files are.

  1. Log into Wordpress at http://jschmoe.watkinswebdev.com/blog/wp-admin/
  2. Click on Settings > General
  3. Now change your Wordpress Address and/or Site Address to reflect the new location. Both of them should be the same: http://jschmoe.watkinswebdev.com/blog/.
  4. Click Save Settings
  5. Visit your blog home page: content should be loading now.

Fix Permalinks

Very likely the home page is working, but clicking into page or post permalinks throws an error. To fix this, we need to get Wordpress to generate a new .htaccess file

  1. In Cyberduck, connect to your web space and double-click into the blog folder.
  2. Make sure your hidden files are being shown (if necessary, choose View > Show Hidden Files).
  3. If you see the .htaccess file, delete it by clicking on it and choosing File > Delete. If it’s not there, I already deleted it.
  4. Disconnect
  5. Now go back to your Wordpress dashboard and choose Settings > Permalinks. Choose Post name or whatever setting you had before. Click Save Changes.
  6. Test your public site: permalink URLs should be working now.

Watkinswebdev.com Server Status

Looks like PHP files aren’t running (no input file specified) on watkinswebdev.com.

3/30, 12pm: Steve has a note in with tech support
4/1, 10pm: Ugh, it looks like Dreamhost changed the rules so that now sub-users cannot run PHP files. Everybody’s data is still there, and we’re looking into alternative setups.
4/2, 1pm: Ok, everyone has been moved to a new space. Please read up on the changes and follow the instructions.