Public feed #889118

Miscellany

public text v1 · immutable
Raw Edit
·published 2008-02-02 18:03 UTC
rendered paste body
<?php

function parse_string($string) {

    $array = array();

    while (stristr($string,'{') == true) {

        /** Find first { */

        $first_pos = strpos($string,'{');

        $last_pos = strpos($string,'}');

        $element = substr($string,$first_pos,($last_pos - $first_pos)+1);

        $array[] = $element;
        $string = str_replace($element,'',$string);

    }

    $rem_elements = explode(' ',$string);
    foreach($rem_elements as $value) {

        if (!empty($value)) {
            $array[] = $value;
        }

    }

    return $array;

    }

?>