Created
March 20, 2012 17:20
-
-
Save RalfAlbert/2138338 to your computer and use it in GitHub Desktop.
Example 1 for Formatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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