- print_r: documentation ( source)
- explode: documentation ( source)
<?php
function assignValuesFromText( $sIn, $dVat = null ){
$aRet = array();
$aPieces = explode( '@@', $sIn );
while ( list( $sKey, $sVal ) = each( $aPieces ) ) {
if ( $sVal ) {
$aName = explode( '__', $sVal );
if ( isset( $aName[0] ) && isset( $aName[1] ) ) {
$aRet[] = $this->_fillExplodeArray( $aName, $dVat );
}
}
}
return $aRet;
}
$string = "Schwarz__@@Weiß__@@Schön!P!10__@@Cool!P!50%__@@";
echo print_r(assignValuesFromText($string),true);