splitting lines in arrays?



Hi, all.

Been staring at this for a couple of hours now and I find myself
completely bewildered. I suppose it doesn't help that I'm a php newbie.
Nevertheless, I throw myself at your mercy.

I have an array which I am attempting to split off into a new array.
The first array is just a whole bunch of links like so:

http://www.example.com/query?track=http://www.somewhereelse.com/whatever.php
http://www.example.com/query?track=http://www.somewhereelse.com/whatever1.php

I managed to (sorta) successfully extract things out using preg_split:

foreach ($http_array as $i) {
$split = preg_split("/=/", $i, 2);
print "$split[1]<br>";
}

and the output looks like

http://www.somewhereelse.com/whatever.php
http://www.somewhereelse.com/whatever1.php
.... and so on...

The main goal is to parse an array much like the first bit at the top,
lop off anything after the first "=" in the line and then place it all
into another blank array so that I might do something else clever
elsewhere with it.

however, i've been totally unsuccessful in cleaning out blank entries
in the array (some creep in there, PREG_SPLIT_NO_EMPTY does not seem to
catch them) and cramming all of that into another new array. Been back
and forth between google and the fine php documents with little to show
for it.

eh. I give up. thoughts?

tom

.



Relevant Pages

  • Re: Unpack - getting values directly into the correct variables
    ... redundant, yes, but I've seen much worse code. ... Maybe a bit too clever for production code. ... I'd use an array of arrays instead: ...
    (comp.lang.perl.misc)
  • Re: Use of ANY
    ... slice of an array, looking for any occurrence of a particular ... Is there a clever way to use the ANY intrinsic for this, ... the actual y and z values.)- Tekst uit oorspronkelijk bericht niet weergeven - ...
    (comp.lang.fortran)
  • Re: Forbidding template instantiation for specific type
    ... Both will confuse an unsuspecting user of the template who isn't "In the ... and I get a link error, I'm gonna be one confused dude, and can't imagine ... I actually found that to be pretty clever! ... trick is giving the array a name that makes the situation obvious, ...
    (comp.lang.cpp)
  • Re: Forbidding template instantiation for specific type
    ... > and I get a link error, I'm gonna be one confused dude, and can't imagine ... I actually found that to be pretty clever! ... > trick is giving the array a name that makes the situation obvious, ...
    (comp.lang.cpp)
  • Re: Needs help with old PHP scrips on new server with update version of PHP
    ... array with the key cart.sum.tax.6". ... I seems to me that whoever wrote the code was being too clever. ... > version of PHP and the latest version that would make variables being ...
    (comp.lang.php)