December 19, 2009, 9:52 am
$colorList = array(0 =>"red",1=>"green",2=>"blue",3=>"black",4=>"white");
foreach( $colorList as $key => $value){
echo "Key: $key, Val: $value ";
}
OUTPUT:
Key: 0, Val: red
Key: 1, Val: green
Key: 2, Val: blue
Key: 3, Val: black
Key: 4, Val: white
December 14, 2009, 1:38 am
December 13, 2009, 11:53 am
Use one of the following tools
- Postable
- HTMLizer
December 13, 2009, 11:43 am
<?php
//Connect to Databse
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($G['dbname']);
?>
<?php
// Simple query returning a single row 'COL_VAL'
$query = " SELECT 'COL_VAL' as COL_VAL ";
//Fetch Result
$result = mysql_query($query) or die('Error2, query failed:'.$query);
//Iterate through Result
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$C_COL_VAL = $row['COL_VAL'];
echo "$C_COL_VAL";
}
?>
<?php
//Closing DB Connection
mysql_close($conn);
?>
December 13, 2009, 11:09 am
Paste the code as “Paste Special” (Edit -> Paste Special)
December 13, 2009, 11:04 am
$mappings = array ('windows' => 'microsoft', 'ipod' => 'apple', 'corby' => 'samsum');
print_r($mappings);
output:
Array ( [windows] => microsoft [ipod] => apple [corby] => samsum )