how to get number from a series of numbers in php

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

swdeveloper
New php-forum User
New php-forum User
Posts: 1
Joined: Tue Apr 01, 2014 5:11 am

how to get number from a series of numbers in php

Postby swdeveloper » Tue Apr 01, 2014 5:20 am

Hello!
I am new in php..
I have a nic number like 41306-2367892-5. I want theses all numbers in different variables like
$variable1=4;
$variable2 =1;
$variable3=3;
$variable4 =0;
$variable5=6;
$variable6 =-;
$variable7=2;
$variable8 =3;
$variable9=6;
$variable10 =7;
$variable11=8;
$variable12 =9;
$variable13=2;
$variable14 =-;
$variable15=5;


can any one help me out????

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: how to get number from a series of numbers in php

Postby seandisanti » Wed Apr 02, 2014 1:27 am

check out str_split() does exactly what you want:

Code: Select all

<?php 
$value 
= '123456789';
$split = str_split($value, 1);
echo '<pre>';
print_r($split);

prints:


Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8
[8] => 9
)


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest