Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > Web Development
You last visited: Today at 01:15

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Newsfeed Frage

Discussion on Newsfeed Frage within the Web Development forum part of the Coders Den category.

Reply
 
Old   #1
 
lnqlorlouz's Avatar
 
elite*gold: 0
Join Date: Jun 2013
Posts: 405
Received Thanks: 84
Smile Newsfeed Frage

Hallo,

hab mir ein Newsfeed geschrieben, nun ist mir eine Idee gekommen, die ich auch noch hinzufügen möchte.
Und zwar, wenn ich in den Neuigkeiten Smileys mache:
Code:
:) :D ;) ...
Das es mir die in Form eines Bildes ausgibt. Dafür muss ich doch irgendwie den Newseintrag verarbeiten bzw. die Smileys finden, wie lasse ich diese herausfiltern quasi ob drin oder nicht drin?

Beispiel:
Code:
Hey, meine Website ist nun wieder online! :)
Wie kann ich jetzt herausfinden, ob ein Smiley gegeben ist?

War etwas blöd erklärt, hoffe aber man versteht es.

Grüße
lnqlorlouz is offline  
Old 07/29/2014, 19:45   #2
 
PixelTree's Avatar
 
elite*gold: 13
Join Date: Feb 2010
Posts: 1,350
Received Thanks: 239

PHP Code:
function replace_smiley($text) {
  
$replacements = array( 
     
":)" => "image1.jpg"
     
":(" => "image2.jpg"
  
);

  
$out $text;
  foreach (
$replacements as $code => $image) {
    
$html '<img src="img/' $image ' alt="' $code '" height="100" width="100" />';
    
$out str_replace($code$html$out);
  }
  return 
$out;

PixelTree is offline  
Thanks
1 User
Old 07/30/2014, 23:16   #3
 
turk55's Avatar
 
elite*gold: 130
Join Date: Oct 2007
Posts: 1,655
Received Thanks: 705
Quote:
Originally Posted by PixelTree View Post

PHP Code:
function replace_smiley($text) {
  
$replacements = array( 
     
":)" => "image1.jpg"
     
":(" => "image2.jpg"
  
);

  
$out $text;
  foreach (
$replacements as $code => $image) {
    
$html '<img src="img/' $image ' alt="' $code '" height="100" width="100" />';
    
$out str_replace($code$html$out);
  }
  return 
$out;

Why are you looping through it ?
You can simply do this:

$text = "hi there ";
$text = str_replace(array("", ""), array("<img src='image1.jpg' />", "<img src='image2.jpg' />"), $text);
turk55 is offline  
Thanks
1 User
Reply




All times are GMT +1. The time now is 01:16.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.