Question about reading data I've created with , delimiter
Hello, could someone please show me how to do this.
In a single cell in a DB column, I can have multiple kinds of data
squeezed together delimited by a comma.
like .....
"datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
"
If I read that data and have it in a string like $datastring...... how
do I put it into a array situation? to access that data.... so if I
want to know what is in spot 5 only, and return back 'datayellow' for
instance, how do I do that? :-) I don't know if array is the right
word, I just want to be able to access any part of that string based
on the order it is in.
Thank you!
Rebecca
Re: Question about reading data I've created with , delimiter
rebeccatre [at] gmail.com wrote:
>
> Hello, could someone please show me how to do this.
>
> In a single cell in a DB column, I can have multiple kinds of data
> squeezed together delimited by a comma.
>
> like .....
> "datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
> "
>
> If I read that data and have it in a string like $datastring...... how
> do I put it into a array situation? to access that data.... so if I
> want to know what is in spot 5 only, and return back 'datayellow' for
> instance, how do I do that? :-) I don't know if array is the right
> word, I just want to be able to access any part of that string based
> on the order it is in.
>
> Thank you!
>
> Rebecca
>
Rebecca,
Try this in comp.databases.mysql - a MySQL newsgroup.
But before you do, google for "database normalization". MySQL has a
decent discussion on it, but some other sites may be better.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex [at] attglobal.net
==================
Re: Question about reading data I've created with , delimiter
On Jul 15, 8:41 pm, Jerry Stuckle <jstuck... [at] attglobal.net> wrote:
> rebecca... [at] gmail.com wrote:
>
> > Hello, could someone please show me how to do this.
>
> > In a single cell in a DB column, I can have multiple kinds of data
> > squeezed together delimited by a comma.
>
> > like .....
> > "datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
> > "
>
> > If I read that data and have it in a string like $datastring...... how
> > do I put it into a array situation? to access that data.... so if I
> > want to know what is in spot 5 only, and return back 'datayellow' for
> > instance, how do I do that? :-) I don't know if array is the right
> > word, I just want to be able to access any part of that string based
> > on the order it is in.
>
> > Thank you!
>
> > Rebecca
>
> Rebecca,
>
> Try this in comp.databases.mysql - a MySQL newsgroup.
>
> But before you do, google for "database normalization". MySQL has a
> decent discussion on it, but some other sites may be better.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck... [at] attglobal.net
> ==================
Jerry is right -- you should fix your database first.
Having said that, have a look at the explode() function in PHP -- it
will take a delimited string and turn it into an array.
<http://www.php.net/explode>
Re: Question about reading data I've created with , delimiter
..oO(rebeccatre [at] gmail.com)
>Hello, could someone please show me how to do this.
>
>In a single cell in a DB column, I can have multiple kinds of data
>squeezed together delimited by a comma.
>
>like .....
>"datagreen,datablue,dataorange,datawhite,datayellow,datared ,datablue, ...
>"
You'll run into trouble with such a design. Read about database
normalization (the above violates the first normal form already).
>If I read that data and have it in a string like $datastring...... how
>do I put it into a array situation?
http://php.net/explode
Micha
Re: Question about reading data I've created with , delimiter
Usually I get a answer in alt.php concerning MYSQL :-) :-)
I've reposted the question below, I have a very large and complex
environment, and this is just the thing I need to do. Can someone
please show a working example? How does the explode() command help me
pull back #5 data slot? Thank you for your patience and anyone can
help that would be great.
-----------
Hello, could someone please show me how to do this.
In a single cell in a DB column, I can have multiple kinds of data
squeezed together delimited by a comma.
like .....
"datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
"
If I read that data and have it in a string like $datastring...... how
do I put it into a array situation? to access that data.... so if I
want to know what is in spot 5 only, and return back 'datayellow' for
instance, how do I do that? :-) I don't know if array is the right
word, I just want to be able to access any part of that string based
on the order it is in.
Thank you!
Rebecca
Re: Question about reading data I've created with , delimiter
<?
$string='datagreen,datablue,dataetc';
$ary = explode($string, ',');
foreach($ary as $a)
{
echo "<p>".$a."</p>\t";
}
?>
explode() creates an array by breaking a string on deliminators (boundries).
Running the above in php should output what's below in the client browser.
datagreen
datablue
dataetc
HTH
Vince
<rebeccatre [at] gmail.com> wrote in message
news:1184544785.598523.147040 [at] q75g2000hsh.googlegroups.com.. .
>
>
> Hello, could someone please show me how to do this.
>
> In a single cell in a DB column, I can have multiple kinds of data
> squeezed together delimited by a comma.
>
> like .....
> "datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
> "
>
> If I read that data and have it in a string like $datastring...... how
> do I put it into a array situation? to access that data.... so if I
> want to know what is in spot 5 only, and return back 'datayellow' for
> instance, how do I do that? :-) I don't know if array is the right
> word, I just want to be able to access any part of that string based
> on the order it is in.
>
> Thank you!
>
> Rebecca
>
Re: Question about reading data I've created with , delimiter
..oO(rebeccatre [at] gmail.com)
>Usually I get a answer in alt.php concerning MYSQL :-) :-)
>
>I've reposted the question below, I have a very large and complex
>environment, and this is just the thing I need to do. Can someone
>please show a working example? How does the explode() command help me
>pull back #5 data slot? Thank you for your patience and anyone can
>help that would be great.
Did you actually read the manual page for explode()? Using it is pretty
easy - you feed a string to it and get an array back. The 5th element of
your string would be the 4th element in the array (zero-based indexes).
Micha
Re: Question about reading data I've created with , delimiter
On Jul 15, 8:09 pm, Michael Fesser <neti... [at] gmx.de> wrote:
> .oO(rebecca... [at] gmail.com)
>
> >Usually I get a answer in alt.php concerning MYSQL :-) :-)
>
> >I've reposted the question below, I have a very large and complex
> >environment, and this is just the thing I need to do. Can someone
> >please show a working example? How does the explode() command help me
> >pull back #5 data slot? Thank you for your patience and anyone can
> >help that would be great.
>
> Did you actually read the manual page for explode()? Using it is pretty
> easy - you feed a string to it and get an array back. The 5th element of
> your string would be the 4th element in the array (zero-based indexes).
>
> Micha
Thank you Micha & Vince, this is kinda the theory that I hope to
figure out. I do understand there is a explode command, but there
isn't sufficient examples out there (or at least I have not found one
yet) related to answer what I would like.
The code example kindly posted by Vince is helpful to understand-see
the explode() command unravel the string, but it doesn't solve the
question I proposed. :( I want to be able to only print part of that
string on demand (5th slot for example).... am I getting close? ;)
Re: Question about reading data I've created with , delimiter
<?
$string='datagreen,datablue,dataetc';
$ary = explode($string, ',');
echo "<p>".$ary[2]."</p>\t";
?>
Should output:
dataetc
HTH
Vince
<rebeccatre [at] gmail.com> wrote in message
news:1184548548.346329.169130 [at] r34g2000hsd.googlegroups.com.. .
> On Jul 15, 8:09 pm, Michael Fesser <neti... [at] gmx.de> wrote:
> > .oO(rebecca... [at] gmail.com)
> >
> > >Usually I get a answer in alt.php concerning MYSQL :-) :-)
> >
> > >I've reposted the question below, I have a very large and complex
> > >environment, and this is just the thing I need to do. Can someone
> > >please show a working example? How does the explode() command help me
> > >pull back #5 data slot? Thank you for your patience and anyone can
> > >help that would be great.
> >
> > Did you actually read the manual page for explode()? Using it is pretty
> > easy - you feed a string to it and get an array back. The 5th element of
> > your string would be the 4th element in the array (zero-based indexes).
> >
> > Micha
>
> Thank you Micha & Vince, this is kinda the theory that I hope to
> figure out. I do understand there is a explode command, but there
> isn't sufficient examples out there (or at least I have not found one
> yet) related to answer what I would like.
>
> The code example kindly posted by Vince is helpful to understand-see
> the explode() command unravel the string, but it doesn't solve the
> question I proposed. :( I want to be able to only print part of that
> string on demand (5th slot for example).... am I getting close? ;)
>
Re: Question about reading data I've created with , delimiter
On Jul 15, 8:29 pm, "Vince Morgan" <vinharAtHereoptusnet.com.au>
wrote:
> <?
> $string='datagreen,datablue,dataetc';
> $ary = explode($string, ',');
> echo "<p>".$ary[2]."</p>\t";
>
> ?>
> Should output:
>
> dataetc
>
> HTH
Zweet Vince --- you are the best
Re: Question about reading data I've created with , delimiter
..oO(rebeccatre [at] gmail.com)
>The code example kindly posted by Vince is helpful to understand-see
>the explode() command unravel the string, but it doesn't solve the
>question I proposed. :( I want to be able to only print part of that
>string on demand (5th slot for example).... am I getting close? ;)
No offense intended, but could it be that you're lacking some very
basics like how to access array elements or to print something out?
Micha
Re: Question about reading data I've created with , delimiter
On Jul 15, 8:29 pm, "Vince Morgan" <vinharAtHereoptusnet.com.au>
wrote:
> <?
> $string='datagreen,datablue,dataetc';
> $ary = explode($string, ',');
> echo "<p>".$ary[2]."</p>\t";
>
> ?>
> Should output:
>
> dataetc
>
> HTH
> Vince<rebecca... [at] gmail.com> wrote in message
>
> news:1184548548.346329.169130 [at] r34g2000hsd.googlegroups.com.. .
>
> > On Jul 15, 8:09 pm, Michael Fesser <neti... [at] gmx.de> wrote:
> > > .oO(rebecca... [at] gmail.com)
>
> > > >Usually I get a answer in alt.php concerning MYSQL :-) :-)
>
> > > >I've reposted the question below, I have a very large and complex
> > > >environment, and this is just the thing I need to do. Can someone
> > > >please show a working example? How does the explode() command help me
> > > >pull back #5 data slot? Thank you for your patience and anyone can
> > > >help that would be great.
>
> > > Did you actually read the manual page for explode()? Using it is pretty
> > > easy - you feed a string to it and get an array back. The 5th element of
> > > your string would be the 4th element in the array (zero-based indexes).
>
> > > Micha
>
> > Thank you Micha & Vince, this is kinda the theory that I hope to
> > figure out. I do understand there is a explode command, but there
> > isn't sufficient examples out there (or at least I have not found one
> > yet) related to answer what I would like.
>
> > The code example kindly posted by Vince is helpful to understand-see
> > the explode() command unravel the string, but it doesn't solve the
> > question I proposed. :( I want to be able to only print part of that
> > string on demand (5th slot for example).... am I getting close? ;)
Vince, maybe I missed something in running this, but I actually got a
empty return :(
Re: Question about reading data I've created with , delimiter
Sorry Rebecca. I should have looked more closely. The parameters for
'explode()' are reversed.
$ary = explode($string, ','); should be as below.
$ary = explode(',', $string);
My appologies,
Vince
<rebeccatre [at] gmail.com> wrote in message
news:1184550344.620682.189780 [at] o61g2000hsh.googlegroups.com.. .
> On Jul 15, 8:29 pm, "Vince Morgan" <vinharAtHereoptusnet.com.au>
> wrote:
> > <?
> > $string='datagreen,datablue,dataetc';
> > $ary = explode($string, ',');
> > echo "<p>".$ary[2]."</p>\t";
> >
> > ?>
> > Should output:
> >
> > dataetc
> >
> > HTH
> > Vince<rebecca... [at] gmail.com> wrote in message
> >
> > news:1184548548.346329.169130 [at] r34g2000hsd.googlegroups.com.. .
> >
> > > On Jul 15, 8:09 pm, Michael Fesser <neti... [at] gmx.de> wrote:
> > > > .oO(rebecca... [at] gmail.com)
> >
> > > > >Usually I get a answer in alt.php concerning MYSQL :-) :-)
> >
> > > > >I've reposted the question below, I have a very large and complex
> > > > >environment, and this is just the thing I need to do. Can someone
> > > > >please show a working example? How does the explode() command help
me
> > > > >pull back #5 data slot? Thank you for your patience and anyone can
> > > > >help that would be great.
> >
> > > > Did you actually read the manual page for explode()? Using it is
pretty
> > > > easy - you feed a string to it and get an array back. The 5th
element of
> > > > your string would be the 4th element in the array (zero-based
indexes).
> >
> > > > Micha
> >
> > > Thank you Micha & Vince, this is kinda the theory that I hope to
> > > figure out. I do understand there is a explode command, but there
> > > isn't sufficient examples out there (or at least I have not found one
> > > yet) related to answer what I would like.
> >
> > > The code example kindly posted by Vince is helpful to understand-see
> > > the explode() command unravel the string, but it doesn't solve the
> > > question I proposed. :( I want to be able to only print part of that
> > > string on demand (5th slot for example).... am I getting close? ;)
>
> Vince, maybe I missed something in running this, but I actually got a
> empty return :(
>
Re: Question about reading data I've created with , delimiter
In our last episode,
<1184544785.598523.147040 [at] q75g2000hsh.googlegroups.com>,
the lovely and talented rebeccatre [at] gmail.com
broadcast on comp.lang.php:
> Hello, could someone please show me how to do this.
> In a single cell in a DB column, I can have multiple kinds of data
> squeezed together delimited by a comma.
> like .....
> "datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
> "
Yes, you could do the same thing with a file-based data system. The point
of using a database is to avoid this sort of thing.
> If I read that data and have it in a string like $datastring...... how
> do I put it into a array situation? to access that data.... so if I
> want to know what is in spot 5 only, and return back 'datayellow' for
> instance, how do I do that? :-) I don't know if array is the right
> word, I just want to be able to access any part of that string based
> on the order it is in.
The best stituation would have been to set up your database properly
(1 cell = 1 datum). As it is, you can use explode on the string which
gives you a one-dimensional array, and the 5th item on the list will
have index 4 in the array (because indices start at 0).
> Thank you!
> Rebecca
--
Lars Eighner <http://larseighner.com/> <http://myspace.com/larseighner>
Countdown: 554 days to go.
Owing to massive spam from googlegroups, I do not see most posts from there.
Re: Question about reading data I've created with , delimiter
rebeccatre [at] gmail.com wrote:
>
> Hello, could someone please show me how to do this.
>
> In a single cell in a DB column, I can have multiple kinds of data
> squeezed together delimited by a comma.
>
> like .....
> "datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
> "
>
> If I read that data and have it in a string like $datastring...... how
> do I put it into a array situation? to access that data.... so if I
> want to know what is in spot 5 only, and return back 'datayellow' for
> instance, how do I do that? :-) I don't know if array is the right
> word, I just want to be able to access any part of that string based
> on the order it is in.
>
> Thank you!
>
> Rebecca
>
Rebecca,
Try this in comp.databases.mysql - a MySQL newsgroup.
But before you do, google for "database normalization". MySQL has a
decent discussion on it, but some other sites may be better.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex [at] attglobal.net
==================
Re: Question about reading data I've created with , delimiter
On Jul 15, 8:41 pm, Jerry Stuckle <jstuck... [at] attglobal.net> wrote:
> rebecca... [at] gmail.com wrote:
>
> > Hello, could someone please show me how to do this.
>
> > In a single cell in a DB column, I can have multiple kinds of data
> > squeezed together delimited by a comma.
>
> > like .....
> > "datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
> > "
>
> > If I read that data and have it in a string like $datastring...... how
> > do I put it into a array situation? to access that data.... so if I
> > want to know what is in spot 5 only, and return back 'datayellow' for
> > instance, how do I do that? :-) I don't know if array is the right
> > word, I just want to be able to access any part of that string based
> > on the order it is in.
>
> > Thank you!
>
> > Rebecca
>
> Rebecca,
>
> Try this in comp.databases.mysql - a MySQL newsgroup.
>
> But before you do, google for "database normalization". MySQL has a
> decent discussion on it, but some other sites may be better.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck... [at] attglobal.net
> ==================
Jerry is right -- you should fix your database first.
Having said that, have a look at the explode() function in PHP -- it
will take a delimited string and turn it into an array.
<http://www.php.net/explode>
Re: Question about reading data I've created with , delimiter
..oO(rebeccatre [at] gmail.com)
>Hello, could someone please show me how to do this.
>
>In a single cell in a DB column, I can have multiple kinds of data
>squeezed together delimited by a comma.
>
>like .....
>"datagreen,datablue,dataorange,datawhite,datayellow,datared ,datablue, ...
>"
You'll run into trouble with such a design. Read about database
normalization (the above violates the first normal form already).
>If I read that data and have it in a string like $datastring...... how
>do I put it into a array situation?
http://php.net/explode
Micha
Re: Question about reading data I've created with , delimiter
Usually I get a answer in alt.php concerning MYSQL :-) :-)
I've reposted the question below, I have a very large and complex
environment, and this is just the thing I need to do. Can someone
please show a working example? How does the explode() command help me
pull back #5 data slot? Thank you for your patience and anyone can
help that would be great.
-----------
Hello, could someone please show me how to do this.
In a single cell in a DB column, I can have multiple kinds of data
squeezed together delimited by a comma.
like .....
"datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
"
If I read that data and have it in a string like $datastring...... how
do I put it into a array situation? to access that data.... so if I
want to know what is in spot 5 only, and return back 'datayellow' for
instance, how do I do that? :-) I don't know if array is the right
word, I just want to be able to access any part of that string based
on the order it is in.
Thank you!
Rebecca
Re: Question about reading data I've created with , delimiter
<?
$string='datagreen,datablue,dataetc';
$ary = explode($string, ',');
foreach($ary as $a)
{
echo "<p>".$a."</p>\t";
}
?>
explode() creates an array by breaking a string on deliminators (boundries).
Running the above in php should output what's below in the client browser.
datagreen
datablue
dataetc
HTH
Vince
<rebeccatre [at] gmail.com> wrote in message
news:1184544785.598523.147040 [at] q75g2000hsh.googlegroups.com.. .
>
>
> Hello, could someone please show me how to do this.
>
> In a single cell in a DB column, I can have multiple kinds of data
> squeezed together delimited by a comma.
>
> like .....
> "datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
> "
>
> If I read that data and have it in a string like $datastring...... how
> do I put it into a array situation? to access that data.... so if I
> want to know what is in spot 5 only, and return back 'datayellow' for
> instance, how do I do that? :-) I don't know if array is the right
> word, I just want to be able to access any part of that string based
> on the order it is in.
>
> Thank you!
>
> Rebecca
>
Re: Question about reading data I've created with , delimiter
..oO(rebeccatre [at] gmail.com)
>Usually I get a answer in alt.php concerning MYSQL :-) :-)
>
>I've reposted the question below, I have a very large and complex
>environment, and this is just the thing I need to do. Can someone
>please show a working example? How does the explode() command help me
>pull back #5 data slot? Thank you for your patience and anyone can
>help that would be great.
Did you actually read the manual page for explode()? Using it is pretty
easy - you feed a string to it and get an array back. The 5th element of
your string would be the 4th element in the array (zero-based indexes).
Micha
Re: Question about reading data I've created with , delimiter
On Jul 15, 8:09 pm, Michael Fesser <neti... [at] gmx.de> wrote:
> .oO(rebecca... [at] gmail.com)
>
> >Usually I get a answer in alt.php concerning MYSQL :-) :-)
>
> >I've reposted the question below, I have a very large and complex
> >environment, and this is just the thing I need to do. Can someone
> >please show a working example? How does the explode() command help me
> >pull back #5 data slot? Thank you for your patience and anyone can
> >help that would be great.
>
> Did you actually read the manual page for explode()? Using it is pretty
> easy - you feed a string to it and get an array back. The 5th element of
> your string would be the 4th element in the array (zero-based indexes).
>
> Micha
Thank you Micha & Vince, this is kinda the theory that I hope to
figure out. I do understand there is a explode command, but there
isn't sufficient examples out there (or at least I have not found one
yet) related to answer what I would like.
The code example kindly posted by Vince is helpful to understand-see
the explode() command unravel the string, but it doesn't solve the
question I proposed. :( I want to be able to only print part of that
string on demand (5th slot for example).... am I getting close? ;)
Re: Question about reading data I've created with , delimiter
<?
$string='datagreen,datablue,dataetc';
$ary = explode($string, ',');
echo "<p>".$ary[2]."</p>\t";
?>
Should output:
dataetc
HTH
Vince
<rebeccatre [at] gmail.com> wrote in message
news:1184548548.346329.169130 [at] r34g2000hsd.googlegroups.com.. .
> On Jul 15, 8:09 pm, Michael Fesser <neti... [at] gmx.de> wrote:
> > .oO(rebecca... [at] gmail.com)
> >
> > >Usually I get a answer in alt.php concerning MYSQL :-) :-)
> >
> > >I've reposted the question below, I have a very large and complex
> > >environment, and this is just the thing I need to do. Can someone
> > >please show a working example? How does the explode() command help me
> > >pull back #5 data slot? Thank you for your patience and anyone can
> > >help that would be great.
> >
> > Did you actually read the manual page for explode()? Using it is pretty
> > easy - you feed a string to it and get an array back. The 5th element of
> > your string would be the 4th element in the array (zero-based indexes).
> >
> > Micha
>
> Thank you Micha & Vince, this is kinda the theory that I hope to
> figure out. I do understand there is a explode command, but there
> isn't sufficient examples out there (or at least I have not found one
> yet) related to answer what I would like.
>
> The code example kindly posted by Vince is helpful to understand-see
> the explode() command unravel the string, but it doesn't solve the
> question I proposed. :( I want to be able to only print part of that
> string on demand (5th slot for example).... am I getting close? ;)
>
Re: Question about reading data I've created with , delimiter
On Jul 15, 8:29 pm, "Vince Morgan" <vinharAtHereoptusnet.com.au>
wrote:
> <?
> $string='datagreen,datablue,dataetc';
> $ary = explode($string, ',');
> echo "<p>".$ary[2]."</p>\t";
>
> ?>
> Should output:
>
> dataetc
>
> HTH
Zweet Vince --- you are the best
Re: Question about reading data I've created with , delimiter
..oO(rebeccatre [at] gmail.com)
>The code example kindly posted by Vince is helpful to understand-see
>the explode() command unravel the string, but it doesn't solve the
>question I proposed. :( I want to be able to only print part of that
>string on demand (5th slot for example).... am I getting close? ;)
No offense intended, but could it be that you're lacking some very
basics like how to access array elements or to print something out?
Micha
Re: Question about reading data I've created with , delimiter
On Jul 15, 8:29 pm, "Vince Morgan" <vinharAtHereoptusnet.com.au>
wrote:
> <?
> $string='datagreen,datablue,dataetc';
> $ary = explode($string, ',');
> echo "<p>".$ary[2]."</p>\t";
>
> ?>
> Should output:
>
> dataetc
>
> HTH
> Vince<rebecca... [at] gmail.com> wrote in message
>
> news:1184548548.346329.169130 [at] r34g2000hsd.googlegroups.com.. .
>
> > On Jul 15, 8:09 pm, Michael Fesser <neti... [at] gmx.de> wrote:
> > > .oO(rebecca... [at] gmail.com)
>
> > > >Usually I get a answer in alt.php concerning MYSQL :-) :-)
>
> > > >I've reposted the question below, I have a very large and complex
> > > >environment, and this is just the thing I need to do. Can someone
> > > >please show a working example? How does the explode() command help me
> > > >pull back #5 data slot? Thank you for your patience and anyone can
> > > >help that would be great.
>
> > > Did you actually read the manual page for explode()? Using it is pretty
> > > easy - you feed a string to it and get an array back. The 5th element of
> > > your string would be the 4th element in the array (zero-based indexes).
>
> > > Micha
>
> > Thank you Micha & Vince, this is kinda the theory that I hope to
> > figure out. I do understand there is a explode command, but there
> > isn't sufficient examples out there (or at least I have not found one
> > yet) related to answer what I would like.
>
> > The code example kindly posted by Vince is helpful to understand-see
> > the explode() command unravel the string, but it doesn't solve the
> > question I proposed. :( I want to be able to only print part of that
> > string on demand (5th slot for example).... am I getting close? ;)
Vince, maybe I missed something in running this, but I actually got a
empty return :(
Re: Question about reading data I've created with , delimiter
Sorry Rebecca. I should have looked more closely. The parameters for
'explode()' are reversed.
$ary = explode($string, ','); should be as below.
$ary = explode(',', $string);
My appologies,
Vince
<rebeccatre [at] gmail.com> wrote in message
news:1184550344.620682.189780 [at] o61g2000hsh.googlegroups.com.. .
> On Jul 15, 8:29 pm, "Vince Morgan" <vinharAtHereoptusnet.com.au>
> wrote:
> > <?
> > $string='datagreen,datablue,dataetc';
> > $ary = explode($string, ',');
> > echo "<p>".$ary[2]."</p>\t";
> >
> > ?>
> > Should output:
> >
> > dataetc
> >
> > HTH
> > Vince<rebecca... [at] gmail.com> wrote in message
> >
> > news:1184548548.346329.169130 [at] r34g2000hsd.googlegroups.com.. .
> >
> > > On Jul 15, 8:09 pm, Michael Fesser <neti... [at] gmx.de> wrote:
> > > > .oO(rebecca... [at] gmail.com)
> >
> > > > >Usually I get a answer in alt.php concerning MYSQL :-) :-)
> >
> > > > >I've reposted the question below, I have a very large and complex
> > > > >environment, and this is just the thing I need to do. Can someone
> > > > >please show a working example? How does the explode() command help
me
> > > > >pull back #5 data slot? Thank you for your patience and anyone can
> > > > >help that would be great.
> >
> > > > Did you actually read the manual page for explode()? Using it is
pretty
> > > > easy - you feed a string to it and get an array back. The 5th
element of
> > > > your string would be the 4th element in the array (zero-based
indexes).
> >
> > > > Micha
> >
> > > Thank you Micha & Vince, this is kinda the theory that I hope to
> > > figure out. I do understand there is a explode command, but there
> > > isn't sufficient examples out there (or at least I have not found one
> > > yet) related to answer what I would like.
> >
> > > The code example kindly posted by Vince is helpful to understand-see
> > > the explode() command unravel the string, but it doesn't solve the
> > > question I proposed. :( I want to be able to only print part of that
> > > string on demand (5th slot for example).... am I getting close? ;)
>
> Vince, maybe I missed something in running this, but I actually got a
> empty return :(
>
Re: Question about reading data I've created with , delimiter
In our last episode,
<1184544785.598523.147040 [at] q75g2000hsh.googlegroups.com>,
the lovely and talented rebeccatre [at] gmail.com
broadcast on comp.lang.php:
> Hello, could someone please show me how to do this.
> In a single cell in a DB column, I can have multiple kinds of data
> squeezed together delimited by a comma.
> like .....
> "datagreen,datablue,dataorange,datawhite,datayellow,datared, datablue, ...
> "
Yes, you could do the same thing with a file-based data system. The point
of using a database is to avoid this sort of thing.
> If I read that data and have it in a string like $datastring...... how
> do I put it into a array situation? to access that data.... so if I
> want to know what is in spot 5 only, and return back 'datayellow' for
> instance, how do I do that? :-) I don't know if array is the right
> word, I just want to be able to access any part of that string based
> on the order it is in.
The best stituation would have been to set up your database properly
(1 cell = 1 datum). As it is, you can use explode on the string which
gives you a one-dimensional array, and the 5th item on the list will
have index 4 in the array (because indices start at 0).
> Thank you!
> Rebecca
--
Lars Eighner <http://larseighner.com/> <http://myspace.com/larseighner>
Countdown: 554 days to go.
Owing to massive spam from googlegroups, I do not see most posts from there.
PHP » alt.php » Question about reading data I've created with , delimiter