Reply to Re: Extract numbers from string

Your name:

Reply:


Posted by Oli Filth on 01/14/06 22:59

zek2005 said the following on 14/01/2006 20:39:
>
> I have a varchar field in my DB with numeric values separates by
> spaces.

Well this is generally a bad idea to start with - one of the principles
of good database design is atomicity, i.e. each field should contain
only one value.

i.e. instead of something like:

ID name values(VARCHAR)
================================
1 Alice 1 28 373
2 Bob 72 182 44

you should use two tables:

ID name
============
1 Alice
2 Bob

personID value(INT)
=====================
1 1
1 28
1 373
2 72
2 182
2 44


Not to mention that storing numeric values in a character-based data
type is a waste of space and processing time.


> I need to extract the numbers to create an array.

But if you must store your info this way, use explode() to extract the
individual values.


--
Oli

[Back to original 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

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