Mr TMedlem sedan maj 20071 147 inlägg
Tanken är att jag ska byta ut mina smilisar i meddelanden mot bilder.
$contact_emoticon_match[":("]; $contact_emoticon_replace["<img src=\"../images/emoticon_unhappy.gif\"/>"];
$contact_emoticon_match[":-("]; $contact_emoticon_replace["<img src=\"../images/emoticon_unhappy.gif\"/>"];
$contact_emoticon_match[";D"]; $contact_emoticon_replace["<img src=\"../images/emoticon_wink_happy.gif\"/>"];
$contact_emoticon_match[";-D"]; $contact_emoticon_replace["<img src=\"../images/emoticon_wink_happy.gif\"/>"];
$contact_emoticon_match[";)"]; $contact_emoticon_replace["<img src=\"../images/emoticon_wink_smile.gif\"/>"];
$contact_emoticon_match[";-)"]; $contact_emoticon_replace["<img src=\"../images/emoticon_wink_smile.gif\"/>"];
$message_text = str_replace($contact_emoticon_match, $contact_emoticon_replace, $message_text);
Antar att jag lägger upp arryen fel, men hoppas att någon är mer vaken än jag och kan se problemmet. Kan jag inte skapa en arrya på det sättet, och finns det då något snyggt sätt att lägga upp det på? (Programmerar alltid för sent)
LedelMedlem sedan dec. 2004735 inlägg
Du skapar en array genom att skriva @contact_emoticon_match[] = ":("; och så vidare!
[":("] skapar en post i din array med :( som index.
PeddaMedlem sedan juni 20004 880 inlägg
Jag gör så här:
$smile_search = array(
":e",
":heart",
":rose",
":thumbup",
":thumbdown",
":q",
":h",
":x",
":P",
":p",
"x(",
":(",
":t",
":)",
":o",
":bla"
);
$smile_replace = array(
"<img src='smilies/biggrin.gif' width='18' height='18' alt='stort flin' />",
"<img src='smilies/heart.gif' width='18' height='18' alt='hjärta' />",
"<img src='smilies/rose.gif' width='18' height='18' alt='ros' />",
"<img src='smilies/thumbup.gif' width='18' height='18' alt='tummen upp' />",
"<img src='smilies/thumbdown.gif' width='18' height='18' alt='tummen ner' />",
"<img src='smilies/confused.gif' width='18' height='18' alt='undrande' />",
"<img src='smilies/cool.gif' width='18' height='18' alt='lugn' />",
"<img src='smilies/cry.gif' width='18' height='18' alt='gråter' />",
"<img src='smilies/drool.gif' width='18' height='18' alt='dreglar' />",
"<img src='smilies/happy.gif' width='18' height='18' alt='glad' />",
"<img src='smilies/mad.gif' width='18' height='18' alt='arg' />",
"<img src='smilies/sad.gif' width='18' height='18' alt='ledsen' />",
"<img src='smilies/sleepy.gif' width='18' height='18' alt='sömnig' />",
"<img src='smilies/smile.gif' width='18' height='18' alt='leende' />",
"<img src='smilies/suprised.gif' width='18' height='18' alt='förvånad' />",
"<img src='smilies/tongue.gif' width='18' height='18' alt='retsam' />"
);
$text = str_replace($smile_search, $smile_replace, $text);
Mr TMedlem sedan maj 20071 147 inlägg
Men kan jag använda en sådan array i komandot str_replace ?
Läser jag ex. på php.net ska det vara följande
$test = "You should eat fruits, vegetables, and fiber every day.";
$healthy = array("fruits", "vegetables", "fiber");
$yummy = array("pizza", "beer", "ice cream");
$newphrase = str_replace($healthy, $yummy, $text);
Mr TMedlem sedan maj 20071 147 inlägg
Pedda skrev:
Jag gör så här:
Jag kan altså inte göra en snygg lösning där jag har tecknen för smilisen och bilden på samma rad ?
LedelMedlem sedan dec. 2004735 inlägg
$contact_emoticon_match[] = ":("; $contact_emoticon_replace[] = "<img src=\"../images/emoticon_unhappy.gif\"/>";
kan kanske fungera!
Mr TMedlem sedan maj 20071 147 inlägg
Ledel - tack ! Precis den lösningen jag sökte.
Tack alla som svarade !
Mr TMedlem sedan maj 20071 147 inlägg
Följdfråga : finns det någon standard på smilisar ? Blev lite förvånad då jag kollade igenom Peddas lista då det var många jag inte kände till.