title - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of title.php
- <?php
- function titleCreate($text,$art, $price)
- {
- //first shorten to max_len
- $max_len = 32; //note: additional text is ~32
- $words = explode(" ",$text);
- $tot_text = "";
- foreach ($words as $word)
- {
- if ((strlen($tot_text)+strlen($word))>$max_len)
- break;
- $tot_text.=" ".$word;
- }
- $tot_text = trim($tot_text);
- //next check art_type and add
- switch ($art)
- {
- case 0: $tot_text.= ": Crochet"; break;
- case 1: $tot_text.= ": Sewing"; break;
- case 2: $tot_text.= ": Knitting"; break;
- case 3: $tot_text.= ": Tunisian"; break;
- }
- $tot_text.= " pattern";
- //next add "FREE" if price=0
- if ($price==0)
- $tot_text = "FREE ".$tot_text;
- //next add Ribblr
- $tot_text.= " | Ribblr";
- return $tot_text;
- }
- echo titleCreate("The big bad wolf",2,0)
- ?>