<?php
$testArray1 = array('key1', 'key2', 'key3');
$testArray2 = array('value1', 'value2', 'value3');
$testArray3 = array_combine($testArray1, $testArray2);
print_r($testArray3);
//Array ( [key1] => value1 [key2] => value2 [key3] => value3 )
// NOTE : Make sure that the 2 arrays have equual
// number of elements
?>
<?php
$testArray1 = array("place" => "kochi", 11, 12);
$testArray2 = array("p", "s", "place" => "Tvm", "Width" => "10", 84);
$testArray3 = array_merge($testArray1, $testArray2);
print_r($testArray3);
//Array ( [place] => Tvm [0] => 11 [1] => 12 [2] => p [3]
//=> s [Width] => 10 [4] => 84 )
?>
<?php
$testArray = array("Value1","Value2", "Value3");
print_r(array_map('strtoupper', $testArray));
// Array ( [0] => VALUE1 [1] => VALUE2 [2] => VALUE3 )
?>
<?php
$testArray=array("key1"=>"Value1","key2"=>"Value2","key3"=>"Value3");
print_r(array_change_key_case($testArray,CASE_UPPER));
//Array ( [KEY1] => Value1 [KEY2] => Value2 [KEY3] => Value3 )
?>
<?php
$testArray = array(2.4, 2.6, 3.5);
print_r(array_map('ceil', $testArray));
// Array ( [0] => 3 [1] => 3 [2] => 4 )
$testArray = array(2.4, 2.6, 3.5);
print_r(array_map('floor', $testArray));
// Array ( [0] => 2 [1] => 2 [2] => 3 )
?>
<?php
$connect = curl_init("http://www.unixsite.com/feed/rss/");
curl_setopt($connect, CURLOPT_RETURNTRANSFER, true);
curl_setopt($connect, CURLOPT_HEADER, 0) ;
$result = curl_exec($connect);
curl_close($connect);
$data = new SimpleXmlElement($result, LIBXML_NOCDATA);
for($i=0;$i<10;++$i) {
if(empty($data->channel->item[$i]->title)) break;
echo $data->channel->item[$i]->title;
echo $data->channel->item[$i]->description;
}
?>
<?php
if(!eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+
(.[a-z0-9-]+)*(.[a-z]{2,3})$", $email))
$errorList[] = "Email address is invalid.";
?>
<?php
if (!preg_match("/^(http(s?)://|ftp://{1})
((w+.){1,})w{2,}$/i", $websitrAddres))
$errorList[]="Invalid Website address. ' ";
?>
<?php
$array = array('this', 'is', 'an array');
echo is_array($array) ? 'True' : 'False'; // True
echo " ";
$var = 'this is a string';
echo is_array($no) ? 'True' : 'False'; // False
?>
<?php
$testString = "FirstName,MiddleName,LastName";
$testArray = split(",",$testString);
print_r($testArray);
//Array ( [0] => FirstName [1] => MiddleName [2] => LastName )
?>
<?php
$testString = "FirstName MiddleName,LastName";
list($first, $middle, $last) = split('[ ,]', $testString);
echo "First Name: $first; MiddleName: $middle; LastName: $last";
?>
Zend | Magento Certified PHP | eCommerce Architect