Skip to content

Instantly share code, notes, and snippets.

@RalfAlbert
Created March 20, 2012 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RalfAlbert/2138338 to your computer and use it in GitHub Desktop.
Save RalfAlbert/2138338 to your computer and use it in GitHub Desktop.
Example 1 for Formatter
<?php
require_once 'class-formatter.php';
class Lister extends Formatter
{
public function get_list( $data = array() ){
$inner = new stdClass();
$values = new stdClass();
foreach( $data as $key => $value ){
$values->key = $key;
$values->item = $value;
$inner->inner .= self::sprintf( '<li>%item%</li>', $values );
}
return self::sprintf( '<ol>%inner%</ol>', $inner );
}
}
$data = array( 'Eins', 'Zwei', 'Drei' );
$list = new Lister();
echo $list->get_list( $data );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment