Learn how to create and access PHP multidimensional arrays

multidimensional-array is an array element which can contain another array as a value, which in turn can hold other arrays as well. Each location in the array can hold another array. multidimensional-arrays can be two-dimensional or three-dimensional array. Example, We have this following user’s table, which holds our user’s information, their Usernames, E-mails and Countries of origin. Username E-mail Country Jordan jordan@yahoo.com USA Beckham beckham@gmail.com UK Uhurukenyata uhuru@gv.ke Kenya Now we need to represent our table in array using PHP. Example ⇓ multidimensional-arrays We will first create an array of users, which is two-dimensional.       <!DOCTYPE html>  <html>    … Continue reading Learn how to create and access PHP multidimensional arrays

PHP Anonymous Functions

Anonymous Functions have no given function name unlike normal functions, this is also known as closures. You will mostly use Anonymous Functions in other php functions as parameters, (callback parameters) Some PHP functions use a function as parameter or as callback function to do part of their work. Let us see show cases here the usort() function sorts an array by values using a user-defined comparison function. Forexample, the usort() function takes two parameters , the array to be sorted and a callable $value_compare_func respectively. This second paramter (the user defined comparison function) gives you the possibilitiy to tell the … Continue reading PHP Anonymous Functions

constants in php

constants in php A constant in PHP is defined or declared by using define() function or by using the const keyword outside a class definition if you are using PHP 5.3.0. or a later version. If you define a constant one time, you can never change it or undefine it again. your constants can only contain boolean, integer, float and string (So called Scalar Data) . Global constants in PHP is assigned through the define() function Example ⇓ Global Constants <!DOCTYPE html>  <html>    <body>      <?php     define(“CONSTANT”, “Hello WebWideTutor!”);     echo CONSTANT;     ?>     </body>  </html> … Continue reading constants in php

php string slice truncate any character in word or in a text

You want to remove the first or last n characters from a string, use substr() The substr() function ist often when you need to slice off the required number of characters from the beginning or end of the string. The substr() function gives you the possibility to slice and dice strings into smaller strings. It accepts three arguments, of which the last is optional: the string to act on, the position to begin slicing at, and the number of characters to return from its start position. A negative value for the third argument tells PHP to remove characters from the end … Continue reading php string slice truncate any character in word or in a text

PHP Change String value behaviour or look

PHP How to Change Strings.Changing and Manipulate Strings in  PHP by using PHP Built-in Functions, strtoupper() ,strtolower()  ,strrev() ,ucfirst(), ucwords() and str_replace() You want to force a string to uppercase, meaning you want to capitalize a string. You can achieve that using the strtoupper() strtoupper function changes every letter of a string to capital letter. Usage: the function takes one string as a parameter input and returns a capitalized string. <?php $string = ‘arsenal is in good shape now’; echo strtoupper($string); ?> Output : ARSENAL IS IN GOOD SHAPE NOW You want to force a string to lowercase, meaning you … Continue reading PHP Change String value behaviour or look

php for web development

What is PHP ? According to the php.net Site “PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML. PHP is a server scripting language for creating dynamic Web pages. Taken directyle from the php Site “What distinguishes PHP from something like client-side JavaScript is that the code is executed on the server, generating HTML which is then sent to the client”. The client would receive the results of running that script, but would not know what the underlying code was. You can even configure your web server to process … Continue reading php for web development