Jump to content
GarryOne

Problema PHP

Recommended Posts

Posted

<meta http-equiv='Content-Type' content='Type=text/html; charset=utf-8' />
<?php
function explode_script($string, $after_word = array()) {
for($i=0;$i<=count($after_word);$i++) {
if(strstr($string,$after_word[$i])) {
$string = explode($after_word[$i], $string);
print_r($string);
for($j=0;$j<=count($string);$j++) {
echo $string[$j].$after_word[$i].'<br />';
}
}

}
}
$string = 'Mama mea are 4 mere. In fiecare zi merg la magazin de patru ori pe zi. Ma gandesc doar la asta. Te iubesc.';
$array = array('mere.','zi.','asta');
echo explode_script($string,$array);
?>

in for, dupa primul explode, $string deja este un array, iar a doua oara, deja nu-i mai pot face explode. Care e rezolvarea in acest caz

Posted

Keep It Simple Stupid


<?php
$string = 'Mama mea are 4 mere. In fiecare zi merg la magazin de patru ori pe zi. Ma gandesc doar la asta. Te iubesc.';
$delimiters = array('mere.','zi.','asta');
echo str_replace($delimiters , ".<br/>" , $string);
?>

I want my cookies

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...