You are here: Re: Extract numbers from string « PHP Programming Language « IT news, forums, messages
Re: Extract numbers from string

Posted by Charlie King on 01/14/06 22:55

On 14 Jan 2006 12:39:27 -0800, in
<1137271167.529986.168260@g14g2000cwa.googlegroups.com>
(comp.lang.php) "zek2005" <esapoznik@gmail.com> wrote:

> Hi friends!
>
> I have a varchar field in my DB with numeric values separates by
> spaces. I need to extract the numbers to create an array.
>
> Example 1: 1820 1823 1825 --> need to be transform into
>
> 1820
> 1823
> 1825
>
> Example 2: 1 5 21 31 <<> must be transform into
> 1
> 5
> 21
> 31
>
> The difference between ex 1 and 2 is that there might be different
> length between numbers.
>
> Can anyone help me???

$myArray = explode(" ", $myString)

explode() splits up the string in its second argument at each
ocurrence of the string in its first argument, and returns the results
into an array.

The manual http://fr.php.net/manual/en/function.explode.php
gives good examples.

Cheers

--
Charlie

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация