how to retrieve substring from string having variable length of character in php?
Posted
by user187580
on Stack Overflow
See other posts from Stack Overflow
or by user187580
Published on 2010-04-09T09:57:10Z
Indexed on
2010/04/09
10:03 UTC
Read the original article
Hit count: 131
php
|string-manipulation
Hello
I have some data in the format of
C222 = 50
C1234P687 = 'some text'
C123YYY = 'text'
C444 = 89
C345 = 3
C122P687 = 'some text'
C122YYY = 'text'
....
....
so basically 3 different forms
- "C" number = value, example - C444 = 89
- "C" number "P" number = value, example - C123P687 = 'some text'
- "C" number "YYY" = value
Only number is of variable length on the left side of (=) sign. Values vary.
I want to store the data in db as
INSERT INTO datatable
c_id = "number after C"
p_id = "number after P" // if it exists for a line of data
value = 'value'
yyy = 'value'
Any ideas how to retrieve these numbers?
Thanks
© Stack Overflow or respective owner