3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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; } function test($input){ $Ret = array(); $pieces = explode('@@', $input); while(list($key, $val) = each($pieces)){ if($val){ $name = explode('__',$val); if(isset($name[0]) && isset($name[1])){ $Ret[] = $name; } } } return $Ret; } $string = "Schwarz__@@Weiß__@@Schön!P!10__@@Cool!P!50%__@@"; echo print_r(test($string),true);
based on sSA7a
Output for 4.3.0 - 7.1.0
Array ( [0] => Array ( [0] => Schwarz [1] => ) [1] => Array ( [0] => Weiß [1] => ) [2] => Array ( [0] => Schön!P!10 [1] => ) [3] => Array ( [0] => Cool!P!50% [1] => ) )