Skip to content

Instantly share code, notes, and snippets.

@JakobTischler
Created February 19, 2012 11:00
Show Gist options
  • Save JakobTischler/1863170 to your computer and use it in GitHub Desktop.
Save JakobTischler/1863170 to your computer and use it in GitHub Desktop.
Merging String with Array
/**
* Merging String with Array
*/
;
<!-- content to be placed inside <body>…</body> -->
<?php
$asdf = array("a", "b", "c", "d");
$strings = "a: 1 / b: 5 / c: 7 / d: 3";
//Ziel: array("a" => "1", "b" => "5", "c" => "7", "d" => "3");
$strings = explode(" / ", $strings);
//== array("a: 1", "b: 5", "c: 7", "d: 3");
foreach ($strings as $string) {
$string = explode(": ", $string);
/* == array("a", "1")
== array("b", "5")
== array("c", "7")
== array("d", "3") */
}
?>
{"view":"split","prefixfree":"1","page":"html"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment