By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,996 Members | 892 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,996 IT Pros & Developers. It's quick & easy.

I need to split an array

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
Oh and is it possible to change the delimeters of an array to pipes?

Jul 17 '05 #2

P: n/a
.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

P: n/a
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

P: n/a
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

P: n/a

<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

P: n/a
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

P: n/a
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.