<?php
$cars = array("Volvo", "BMW", "Toyota");
echo "I like " . $cars[0] . ", " . $cars[1] . " and " . $cars[2] . ".";
?>
1 Response
In this case it's faster to echo with a comma -- echo 'I like ', $cars[0], ', and so on... '; than to build a concatenated string before echoing out the contents. Also as of PHP 5.6 you should use the new syntax for array declarations and not the old style of array(); $cars = ['Volvo', 'BMW', 'Toyota']; // similar to javascript.
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.
1 Response
Write a comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.