# Control structure - Comparisons Most control structures used within PHP view templates are supported natively in Picea. The goal for this project always has been to not loose original feature while removing some limitations with PHP's original templating syntax. ## Comparison using `if` / `then` / `else` / `elseif` / `endif` Comparisons works the same way as using PHP's alternative syntax. This is also how they are rendered in the compilation process. **[PICEA]** So, using this code: ```html {% php $search = 'Pack my box with five dozen liquor jugs' %} {% if strpos($search, 'beer') !== false %} Found 'beer' into {{ $search }} ! {% elseif strpos($search, 'liquor') !== false %} Found 'liquor' into {{ $search }} ! {% else %} Neither 'beer' or 'liquor' were found in {{ $search }} {% endif %} ``` **[PHP]** Would yield: ```php Found 'beer' into ! Found 'liquor' into ! Neither 'beer' or 'liquor' were found in ``` And then, the code would be runned through PHP's native `include` mechanic. ## Comparison using `switch` / `case` / `break` / `endswitch` Using switches within HTML in plain PHP can be quite cumbersome because of it's limitation disallowing any output (including whitespace) between it's statement. Picea will allow some more complex (and readable) switches within your views. **[PICEA]** So, using this code: ```php {% php $selected = random_int(0,5) %} {% switch $selected %} {% case 1 %} {{ "One person selected" }} {% break %} {% case 2 %} {% default %} {{ "Multiple person ($selected) selected" }} {% break %} {% endswitch %} ``` **[PHP]** Would render as such: ```php ```