array_split ()

function array_split ($source, $divider = ';', $as_key = 0)

This function will split $source to two groups of arrays.

$source can be a string or an array.

$divider is required if the source is a string.

$as_key set to true if you want the odd values to be the array keys.

Example 1

<?php
require './includes/user_init.php';
$string = '1;abc;2;def';
$arr = array (1, 'abc', 2, 'def');

// this will result in multi dimension array
// (array (1 => 1, 2 => 2 ), array (1 => 'abc', 2 => 'def'));
print_r (array_split ($string, ';'));

// same with above, only the input is an array
print_r (array_split ($arr));

// this will result in Array ( [1] => abc [2] => def )
print_r (array_split ($string, ';', true));

// same with above, only the input is an array
print_r (array_split ($arr, '', true));
?>

: @ 07:00am
Last Updated: @ 07:00am

There is no comment. Why not be the first?

More Comments/Post Your Own

Advertisement

Latest Comments

Most Commented

Online Users

There are 131 users online.

Connect

Connect with us on Facebook

Newsletter

Subscribe to our newsletter for the latest updates and exciting promotions!