Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exploding Array 1

Status
Not open for further replies.

Olavxxx

Programmer
Sep 21, 2004
1,134
NO
Hi!

Kunstnere_3/foo_2/na_2Array
gets exploded to:
( [0] => [1] => Kunstnere_3 [2] => foo_2 [3] => na_2 )

I then want to explode this, on _
the key, should be whats before _
the value, should be the integer.

This will be used for queries..

eg. querystring:
Kunstnere_3/foo_2/na_2Array

will result in:
$array["kunstnere"] = 3
$array["foo"] = 2
etc etc

How do I explode like that?
I guess I have to loop the array I already exploded and then explode it and add it to the other query?



Olav Alexander Mjelde
Admin & Webmaster
 
How about this?
Code:
$str = "Kunstnere_3/foo_2/na_2Array";
$str = str_replace("/", "&", $str); // Kunstnere_3&foo_2&na_2Array
$str = str_replace("_", "=", $str); // Kunstnere=3&foo=2&na=2Array
parse_str($str, $arr);
echo $arr['Kunstnere']; // echoes 3
echo $arr['foo']; // echoes 2

--Chessbot

"In that blessed region of Four Dimensions, shall we linger on the threshold of the Fifth, and not enter therein? Ah, no! [...] Then, yielding to our intellectual onset, the gates of the Sixth Dimension shall fly open; after that a Seventh, and then an Eighth -- --" Flatland, A. Square (E. A. Abbott)
 
hmm..
thank you!

after some drinks of B52 and checkers-drinks, I think I should leave up the testing of this code to tomorrow..

thank you for your input, I really appricciate it.

I'll give you a star for this, and get on the testing tomorrow.

when it's done, I'll release the code here.
I think the script is genious, as far as search-engines and it can also trick the user into thinking he is visiting some completely other page than he is.. (htaccess tricks)

anyways, merry christmas/x-mas/hannukah to all of you! even though the day is technically gone.. so is my brain, with the alcohol :p

Olav Alexander Mjelde
Admin & Webmaster
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top