Created
November 14, 2013 09:51
-
-
Save ugurerkan/7464227 to your computer and use it in GitHub Desktop.
PHP lipsum text generator
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 | |
function loremGen($max) | |
{ | |
$str = ''; | |
$lorem = array('Lorem ipsum dolor sit amet, consectetur adipiscing elit. ', | |
'Nunc pharetra urna mi. ', | |
'Suspendisse semper ipsum et leo varius, id posuere odio interdum. ', | |
'Pellentesque ut turpis porttitor, scelerisque felis eget, malesuada dolor. ', | |
'Ut nec ultrices nibh. Proin eleifend adipiscing lectus quis volutpat. ', | |
'Phasellus viverra turpis vitae massa interdum, eu fringilla mi vehicula. ', | |
'Maecenas et tincidunt mauris. ', | |
'Nunc magna purus, pharetra sit amet suscipit non, blandit et ante. ', | |
'Integer feugiat dignissim arcu id pulvinar. ', | |
'Etiam sed lectus vitae est malesuada sagittis. ', | |
'Quisque commodo urna vel justo eleifend luctus eu sed mauris. ', | |
'Etiam non velit molestie, condimentum elit vel, imperdiet ipsum. ', | |
'Proin eleifend ut orci vel lobortis. ', | |
'Morbi in nibh nulla. ', | |
'Nunc eget adipiscing velit.', | |
'Nam libero nisi, imperdiet ac pulvinar vel, gravida id erat. ', | |
'Mauris pellentesque felis id nisi condimentum tempus. ', | |
'Vestibulum tincidunt non elit et pellentesque. ', | |
'Etiam et augue metus. ', | |
'Phasellus non mollis felis. ', | |
'Vivamus at cursus neque. ', | |
'Etiam luctus dolor massa, et semper mauris malesuada vitae. ', | |
'Nam at sapien ac magna posuere consequat. ', | |
'Proin porttitor magna eu dui adipiscing, vel convallis dolor placerat. ' | |
); | |
while($max--) | |
{ | |
shuffle($lorem); | |
$str .= current($lorem); | |
} | |
return $str; | |
} | |
// Sample use | |
$count = 5; | |
while($count--) | |
{ | |
$data = new stdClass(); | |
$data->title = $this->loremGen(1); | |
$data->featured = $this->loremGen(5); | |
$data->detail = $this->loremGen(20); | |
$this->db->insert('news',$data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment