Tue Nov 11, 2008 12:13 am
<? $namesArray = array("Joe", "Jane", "Bob", "Mary", "Paul", "Eddie", "John");
$lookingFor = "Albert";
if (in_array($lookingFor, $namesArray)) {
echo "You've found it!";
} else {
echo "Not found in this array!";
}
?>
<? $namesArray = array("Joe", "Jane", "Bob", "Mary", "Paul", "Eddie", "John");
$count = count($namesArray); ?>
<? /* create the original array */
$fruitArray = array("apple", "orange", "banana", "kiwi", "pear");
/* add to the original array */
array_push($fruitArray, "grape", "pineapple", "tomato");
/* list each element, with its key */
while (list($key,$value) = each($fruitArray)) {
echo "$key : $value<br>";
}
?>
0 : apple
1 : orange
2 : banana
3 : kiwi
4 : pear
5 : grape
6 : pineapple
7 : tomato
<?
/* create the original array */
$fruitArray = array("apple", "orange", "banana", "kiwi", "pear");
/* add to the original array */
array_unshift($fruitArray, "grape", "pineapple", "tomato");
/* list each element, with its key */
while (list($key,$value) = each($fruitArray)) {
echo "$key : $value<br>";
}
?>
0 : grape
1 : pineapple
2 : tomato
3 : apple
4 : orange
5 : banana
6 : kiwi
7 : pear
<? /* create the first array */
$fruitArray = array("apple", "orange", "banana", "kiwi", "pear");
/* create the second array */
$vegArray = array("carrot", "green beans", "asparagus", "artichoke", "corn");
/* merge the arrays into one */
$goodfoodArray = array_merge($fruitArray, $vegArray);
/* list each element, with its key */
while (list($key,$value) = each($goodfoodArray)) {
echo "$key : $value<br>";
}
?>
0 : apple
1 : orange
2 : banana
3 : kiwi
4 : pear
5 : carrot
6 : green beans
7 : asparagus
8 : artichoke
9 : corn
<?
/* create an array */
$fruitArray = array("apple", "orange", "banana", "kiwi", "pear");
/* pop something off the end */
$popped = array_pop($fruitArray);
/* list the contents of the new array, as well as the value you popped off */
while (list($key,$value) = each($fruitArray)) {
echo "$key : $value<br>";
}
echo "<br>and finally, in $popped: $popped";
?>
<?
/* create an array */
$fruitArray = array("apple", "orange", "banana", "kiwi", "pear");
/* shift something from the beginning */
$shifted = array_shift($fruitArray);
/* list the contents of the new array, as well as the value you shifted off */
while (list($key,$value) = each($fruitArray)) {
echo "$key : $value<br>";
}
echo "<br>and finally, in $shifted: $shifted";
?>
0 : orange
1 : banana
2 : kiwi
3 : pear
<? /* create the original array */
$fruitArray = array("apple", "orange", "banana", "kiwi", "pear");
/* sort the array */
sort($fruitArray);
/* reset it so you can display it properly from beginning to end */
/* list each element, with its key */
while (list($key,$value) = each($fruitArray)) {
echo "$key : $value<br>";
}
?>
0 : apple
1 : banana
2 : kiwi
3 : orange
4 : pear
Sun Feb 15, 2009 3:59 pm
Sat May 23, 2009 12:39 pm
Sun Jul 19, 2009 8:08 am
Wed Jul 22, 2009 11:30 am
Wed Jul 29, 2009 2:49 pm
$new_dir = 'uploads/';
$this_file_name = strtolower($_FILES['userfile']['name']);
copy("$userfile", $new_dir . $this_file_name);
Wed Jul 29, 2009 11:28 pm
Thu Jul 30, 2009 6:06 am
Sat Feb 20, 2010 5:33 pm
Jayne Carreen wrote:Hi,
How do I take information from a session and add it to a database? I want to take the persons username of the person submitting a the form and add it to a database.
if(isset($_SESSION['username']))
{
// code here to take value from $_SESSION['username']
}
else
{
echo " User Not Logged In " ;
}
Sun Feb 21, 2010 3:05 pm
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.