سؤال

الآن لدي مشكلة eregi_replace:

لدي هذا

$subject = "This is for @codeworxx - you have to try first!";
$text = eregi_replace('(((@))[-a-zA-Z0-9]+)','<a href="http://www.google.de/\\1">\\1</a>', $subject);
echo $text;

كل شيء يعمل بشكل جيد ، لكن

<a href="http://www.google.com/@codeworxx">@codeworxx</a>

لكني أريد هذا:

<a href="http://www.google.com/codeworxx">codeworxx</a>

كيف تفعل؟

شكرا ، ساشا

هل كانت مفيدة؟

المحلول

<?php
$subject = "This is for @codeworxx - you have to try first!";
$text = eregi_replace('@([-a-zA-Z0-9]+)','<a href="http://www.google.de/\\1">\\1</a>', $subject);
echo $text;
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top