Monday, June 23, 2014

PHP explode() Function

Definition and Usage

The explode() function breaks a string into an array.
Note: The "separator" parameter cannot be an empty string.
Note: This function is binary-safe.

Example

Break a string into an array:
<?php
$str = "My name is KC Verma";
print_r (explode(" ",$str));
?>

Result -
Array ([0] => My [1]=>name [2]=> is [3]=> KC [4] => Verma)

Syntax

explode(separator,string,limit)

ParameterDescription
separatorRequired. Specifies where to break the string
stringRequired. The string to split
limitOptional. Specifies the number of array elements to return.Possible values:
  • Greater than 0 - Returns an array with a maximum of limit element(s)
  • Less than 0 - Returns an array except for the last -limit elements()
  • 0 - Returns an array with one element

12 comments:

  1. that was awesome information thanks for sharing i know this is common one and every php developer have knowledge about it but i'm sure this will help to a person who is new in php

    ReplyDelete
  2. This is very informative post to help learners, who want to work in drupal development

    ReplyDelete
  3. This is Awesome Wonderful Information.. Very Nice.. Useful information Thanks.

    ReplyDelete
  4. Thank you for your post, I look for such article along time, today i find it finally. this post give me lots of advise it is very useful for me
    Signature:
    download free Descargar Whatsapp Para Android and download baixar whatsapp para celular online and descargar whatsapp , baixar whatsapp gratis

    ReplyDelete
  5. Nice Information about the Drupal. Open Source CMS development is one of the most scalable choices for variety of businesses.

    ReplyDelete
  6. Thank you for your post, I look for such article along time, today i find it finally. this post give me lots of advise it is very useful for me
    Signature:
    facebook entrar iniciar sesion gratis - Sitio Oficial iniciado sesión en Facebook lengua española. facebook entrar rápido, facebook iniciar sesion en tu cuenta de entrar facebook

    ReplyDelete
  7. Great info. I love all the posts, I really enjoyed, I would like more information about this, because it is very nice., Thanks for sharing.
    Signature:
    download facebook movel, baixar Facebook movel, baixar facebook. Facebook chat, baixar whatsapp, fazer o download whatsapp baixar para Android, iPhone. Últimas Facebook

    ReplyDelete
  8. This is extremely helpful info!! Very good work. Everything is very interesting to learn and easy to understood. Thank you for giving information.
    Signature:
    Versión en facebook español a los países hablan Español: facebook login entrar , facebook en español para and facebook entrar direto

    ReplyDelete

only show translated menu items into current language (Drupal 8)

function MY_THEME_preprocess_menu(&$variables) {   if ($variables['menu_name'] == 'brancott-header-menu') {    $langu...