472,119 Members | 1,241 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

I need to split an array

array("a", "b", "c", "d", "e");

I want to now be able to load "b" into a variable ($var) then print it
out

print $var

thanks!

Jul 17 '05 #1
7 11635
Oh and is it possible to change the delimeters of an array to pipes?

Jul 17 '05 #2
.oO(br**********@gmail.com)
Oh and is it possible to change the delimeters of an array to pipes?


Hmm? What delimiters?

Micha
Jul 17 '05 #3
br**********@gmail.com wrote:
array("a", "b", "c", "d", "e");

I want to now be able to load "b" into a variable ($var) then print it
out

print $var


It seems to me like it is time to RTFM. You should lookup arrays
(http://nl.php.net/manual/en/language.types.array.php) and assignment of
variables (like example 12-11 on`
http://nl.php.net/manual/en/language...s.external.php)
Jul 17 '05 #4
br**********@gmail.com wrote:
Oh and is it possible to change the delimeters of an array to pipes?


No, atleast not like: array("a"|"b");

You could use an intermediate string and explode that into an array, see
example 2 on http://nl.php.net/manual/en/function.explode.php
Jul 17 '05 #5

<br**********@gmail.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
array("a", "b", "c", "d", "e");
I want to now be able to load "b" into a variable ($var) then print it
out

print $var


array basics.

$var1 = array("a", "b", "c", "d", "e");
$var2= $var1[1]; //element at index 1 contains "b"
echo $var2;

Jul 17 '05 #6
On Tue, 11 Jan 2005 17:36:43 -0800, brianshields wrote:
Oh and is it possible to change the delimeters of an array to pipes?


Delimiters appear in strings. Delimiters in arrays is meaningless.

You are getting array usage confused a little. You don't "split" an
array! An array is formed when you "split()" a string, however.

examples:
<?php
$str = "a,b,c,d,e,f";
$ary = split(",", $str);

echo $ary[2]; // Outputs "c"
?>

<?php
$ary = array("a","b","c","d","e");
$str = join(",",$str); // puts array together into a string
echo $str; // Outputs "a,b,c,d,e"
?>

later...
--
Jeffrey D. Silverman | je**********@jhu.edu
Website | http://www.newtnotes.com

Drop "PANTS" to reply by email

Jul 17 '05 #7
Thanks! I do RTFM and i get lost. Newb. what can i say. Thanks for
spending an extra 5 minutes and explaining it.

Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by AutoShutdown | last post: by
7 posts views Thread by fox | last post: by
2 posts views Thread by sorobor | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.