Skip to content

PHPCodez

Search
  • PHP
  • Magento
  • Javascript
  • HTML
  • My SQL
  • Functions
  • WordPress
  • Plugins
  • Joomla
  • Linux
  • jQuery
  • Profile
  • comments

Monthly Archives: May 2011

PHP

Fetch previous element of an array – PHP

May 11, 2011 Pramod T P Leave a comment
<?php
 $testArray = array('foot', 'bike', 'car', 'plane');
 next($testArray);  next($testArray);
 echo prev($testArray); // bike
?>
ArrayPHPString functions
PHP

Fetch current element of an array – PHP

May 11, 2011 Pramod T P Leave a comment
<?php
 $testArray = array('foot', 'bike', 'car', 'plane');
 echo current($testArray);    // foot
?>
ArrayPHPString functions
PHP

Find out the next element of an array – PHP

May 11, 2011 Pramod T P Leave a comment
<?php
 $testArray = array('foot', 'bike', 'car', 'plane');
 secho next($testArray);    // bike
?>
ArrayPHPString functions
PHP

Function to exchanges keys with their associated values in an array – PHP

May 11, 2011 Pramod T P Leave a comment
<?php
 $testArray = array("key1" => "Value1","key2" => "Value2","key3" => "Value3");
 $testArray = array_flip($testArray);
 print_r($testArray);
 //Array ( [Value1] => key1 [Value2] => key2 [Value3] => key3 )
?>
ArrayPHPString functions
PHP

Sum of elements of an array – PHP

May 11, 2011 Pramod T P Leave a comment
<?php
 $testArray	= array(5, 3, 8, 10);
 echo  "Sum is : ".array_sum($testArray) ;
 //Sum is : 26
?>
ArrayPHPString functions
PHP

function to checks whether given key or index exists in the array – PHP

May 11, 2011 Pramod T P Leave a comment
<?php
 $search_array = array('key1' => 17, 'key2' => 74);
 if (array_key_exists('key1', $search_array)) {
    echo "The key 'key1' exists ";
 }
 //The key 'key1' exists
?>
ArrayPHPString functions
PHP

Function to find out the number of occurrence elements in an array -PHP

May 11, 2011 Pramod T P Leave a comment
<?php
 $testArray=array("Value1","Value1","Value1","Value2");
 print_r(array_count_values($testArray));
 //Array ( [Value1] => 3 [Value2] => 1 )
?>
ArrayPHPString functions
PHP

Creates an array by using one array for keys and another for its values – PHP

May 11, 2011 Pramod T P Leave a comment
<?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
?>
ArrayPHPString functions
PHP

Function to combine arrays – PHP

May 11, 2011 Pramod T P Leave a comment
<?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 )
?>
ArrayPHPString functions
PHP

Convert the values of an array into uppercase – PHP

May 11, 2011 Pramod T P Leave a comment
<?php
 $testArray = array("Value1","Value2", "Value3");
 print_r(array_map('strtoupper', $testArray));
 // Array ( [0] => VALUE1 [1] => VALUE2 [2] => VALUE3 )
?>
ArrayPHPString functions

Posts navigation

← Previous 1 … 4 5 6 7 Next →

Beginners' Guide

Recent Posts

  • Upstream sent too big header while reading response
  • Navigate to a Folder from Any Location by Typing a Letter – Linux
  • Magento 2 Admin Content Deployment
  • React vs next JS
  • Disable CAPTCHA Magento 2 Admin Login
  • Difference Between composer.json and composer.lock Files
  • Magento 2 Regenerate URL Rewrites Manually For Categories
  • Magento 2 Regenerate URL Rewrites Manually for Products
  • composer self downgrade

Recent Comments

  • sunny on cgi.force_redirect
  • beats solo 4 on allow_url_include
  • Hairstyles on php end of line
  • penipu on cgi.force_redirect
  • lumi777 link alternatif on cgi.force_redirect

Categories

  • .htaccess (32)
  • Ajax (4)
  • Apache (43)
  • AWS (11)
  • Cookie (4)
  • Database Model (9)
  • Design Pattern (9)
  • Filter (27)
  • General (187)
  • HTML (5)
  • IP.Board (1)
  • Javascript (99)
  • Jetty (3)
  • Joomla (17)
  • jQuery (63)
  • JSON (3)
  • JSP (1)
  • Linux (125)
  • Magento (371)
  • My SQL (74)
  • nginx (4)
  • OOPs (12)
  • Payment Gateway (1)
  • PHP (1,005)
  • Plugins (11)
  • Prototype (1)
  • session (5)
  • Socialengine (1)
  • SQL (69)
  • SVN (17)
  • Uncategorized (11)
  • Vbulletin (11)
  • Wordpress (89)
Proudly powered by WordPress