സ്ട്രിംഗുകളിൽ നിന്ന് PHP നമ്പറുകൾ വേർതിരിച്ചെടുക്കുക

PHP-യിലെ നമ്പറുകളിലേക്ക് കോമകൾ ചേർക്കുന്നത് എങ്ങനെ?
PHP-യിലെ മാസത്തെ പേരിലേക്ക് നമ്പർ പരിവർത്തനം ചെയ്യുക

ഈ പരിഹാരം 0-കൾ അവഗണിച്ച് സ്ട്രിംഗുകളിൽ നിന്ന് സംഖ്യകൾ വേർതിരിച്ചെടുക്കുകയും മൂന്ന് സ്ട്രിംഗ് നമ്പറുകളായി വേർതിരിക്കുകയും ചെയ്യും.

പരിഹാരം 1.

$string = '02300103024000100';
$output = array();
// First we replace any '00...' string with just '0'
for($a=strlen($string); $a>0; $a--){
   $zero_replace = '';
   while(strlen($zero_replace) < $a) $zero_replace .= '0';
   $string = str_replace($zero_replace,'0',$string);
}
// Now we remove '0' from beginning and end of string (if they exist)
if(substr($string,0,1) == '0') $string = substr($string,1);
if(substr($string,-1,1) == '0') $string = substr($string,0,strlen($string)-1);
// Finally, explode by '0'
$output = explode('0',$string);
print_r($output);

ഔട്ട്പുട്ട്

Array ( [0] => 23 [1] => 1 [2] => 3 [3] => 24 [4] => 1 )

PHP-യിലെ നമ്പറുകളിലേക്ക് കോമകൾ ചേർക്കുന്നത് എങ്ങനെ?
PHP-യിലെ മാസത്തെ പേരിലേക്ക് നമ്പർ പരിവർത്തനം ചെയ്യുക

PHP-യെ കുറിച്ച് കാലികമായിരിക്കുക!

ഞങ്ങൾ സ്പാം ചെയ്യുന്നില്ല!

en English
X
ടോപ്പ് സ്ക്രോൾ