Jump to content
php.lv forumi

No direktorijas visiem failiem dabūt nosaukumus...


daGrevis

Recommended Posts

Labvakar, programmētāji,

 

Negribas manuāli visiem smaidiņiem, kas atrodās direktorijā (/images/smilies) norakstīt nosaukumu, noņemt paplašinājumu, ielikt starp zvaignītēm, to visu ielikt array'ā. Un to visu kādas 300 reizes. xD

 

Tad nu to kaut kā vajadzētu optimizēt! O.o

 

Beigās domāts, ka ja lietotājs ievada kādu smaidiņu, izvadās tā attēls no mapītes.

 

Nepabeigtā funkcija (piemērs kā vēlos):

 

function parse__smilies( $string )
{

$smilies = array(

	'*act-up*' => '<img src="images/smilies/act-up.png" alt="" />'

);

$string = strTr( $string, $smilies );


return $string;

}

 

Idejas? =)

Link to comment
Share on other sites

$arr = array(":)"=>"smily.png", ":(" => "sad.png", ..);
foreach($arr as $key => $value){
$text = str_replace($key, "<img src=\'/img/smilies/$value\'alt=\'$key\'/>", $text);
}

...var visu bez cikliem, bet tad jāraksta pilns ceļš pie katra smailija...

Link to comment
Share on other sites

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.

Loading...
×
×
  • Create New...