my code stock.com

Arrays ausprobieren

Snippet options

Download: Download snippet as arrayphp.php.
Copy snippet: For this you need a free my code stock.com account.
Embed code : You will find the embed code for this snippet at the end of the page, if you want to embed it into a website or a blog!

<?php
$buchstaben = array("J","E","N","P","S","A","D","A","S","E","H","F","P","C","R","N","K","M","I","U","T"); echo "<br />alt: ".$buchstaben[2]; //lesen
$buchstaben[2] = "O"; // schreiben
echo "<br />neu: ".$buchstaben[2]; // Lesen
echo "<br />Elementzahl:" .count($buchstaben);  //wieviele buchstaben sind im array
$buchstaben[] = "Y"; // neues Element anhängen
echo "<hr><br />";
print_r($buchstaben);
echo "<hr><br />";
echo "<br />7 Scrabble-Buchstaben:";
$rand_keys = array_rand($buchstaben, 7);
echo "<br />".$buchstaben[$rand_keys[0]] . "\n";
echo $buchstaben[$rand_keys[1]] . "\n";
echo $buchstaben[$rand_keys[2]] . "\n";
echo $buchstaben[$rand_keys[3]] . "\n";
echo $buchstaben[$rand_keys[4]] . "\n";
echo $buchstaben[$rand_keys[5]] . "\n";
echo $buchstaben[$rand_keys[6]] . "\n";
echo "<hr><br />";
//array mit for-schleife ausgeben
for($i=0;$i<count($buchstaben);$i++)
{
echo $buchstaben[$i]."<br />";
}
echo "<hr><br />";
//fuegt arrayfelder zu zeichenkette zusammen
$wort = implode("",$buchstaben);
echo $wort;
echo "<hr><br />";
$satz ="Ein Becher Kaffee";
$woerter = explode(" ",$satz);
print_r($woerter);

?>

Create a free my code stock.com account now.

my code stok.com is a free service, which allows you to save and manage code snippes of any kind and programming language. We provide many advantages for your daily work with code-snippets, also for your teamwork. Give it a try!

Find out more and register now

You can customize the height of iFrame-Codes as needed! You can find more infos in our API Reference for iframe Embeds.