This is Common task In PHP and other programming languages.I moved from PHP developer. I want to make sure with this collections. Anyone have who good in python please help me to understand clearly . This is my collections from PHP code.
<?php
$php = array(1,2,3,4,5,6,7,8,9,10);
for ($i = 0; $i < 10 ; $i ++)
echo $php[$i]."<br>";
?>
=>What is in Python?
<?php
for ($i = 0; $i < 10 ; $i ++)
echo $php[$i] = $i +1 ;
?>
=>What is in Python?
<?php
$php = array(1,2,3,4,5,6,7,8,9,10);
foreach ($php as $value)
echo $value."<br>";
?>
=>What is in Python?
<?php
$arr = array(1, 2, 3, 4);
foreach ($arr as &$value) {
$value = $value * 2;
}
// $arr is now array(2, 4, 6, 8)
?>
=>What is in Python?
<?php
$arr = array("mot"=>"one", "hai"=>"two","ba"=> "three");
foreach ($arr as $key => $value) {
echo "Key: $key; Value: $value<br />\n";
}
?>
=>What is in Python?
<?php
$arr = array("one", "two","three");
while (list($key, $value) = each($arr)) {
echo "Key: $key; Value: $value<br />\n";
}
?>
=>What is in Python?
<?php
$arr = array("one", "two","three");
while ($element = each($arr)) {
echo "Key: $element['key']; Value: $element['value']<br />\n";
}
?>
=>What is in Python?
<?php
$products = array( array("ITL","INTEL","HARD"),
array("MIR", "MICROSOFT","SOFT"),
array("Py4C", "pythonkhmer.wordpress.com","TUTORIAL")
);
for ($row = 0; $row < 3; $row++)
{
for ($col = 0; $col <3; $col++)
{
echo "|".$products[$row][$col];
}
echo "<br>";
}
?>
=>What is in Python?