/
  • مشکل در کار با str_replace لطفا کمک کنید

  • ارسال پاسخ   امتیاز موضوع:
    • 0 رأی - میانگین امیتازات: 0
    • 1
    • 2
    • 3
    • 4
    • 5

    حالت موضوعی | حالت خطی مشکل در کار با str_replace لطفا کمک کنید
    نویسنده پیام
    kiarash_kcm آفلاین
    عضو
    ***

    ارسال‌ها: 159
    تاریخ عضویت: ۱۳۹۲ بهمن ۷
    اعتبار: 5
    تشکرها : 12
    ( 48 تشکر در 41 ارسال )
    ارسال: #1
    مشکل در کار با str_replace لطفا کمک کنید
    سلام من کد زیر رو میخوام جوری درست کنم که <br> رو تو خروجیم بتونم نشون بدم اگه ممکن هست اساتید کمک کنن این کد رو درست کنم ممنون:

    کد:
    $message = array("72","105","103","104","32","116","114","97","102","102","105","99","32","102","105",
    "110","97","110","99","105","97","108","32","119","101","98","115","105","116","101",
    "32","105","115","32","108","111","111","107","105","110","103","32","102","111","114",
    "32","115","107","105","108","108","101","100","32","97","110","100","32","109","111",
    "116","105","118","97","116","101","100","32","115","111","102","116","119","97","114",
    "101","32","100","101","118","101","108","111","112","101","114","115","32","116","111",
    "32","106","111","105","110","32","111","117","114","32","116","101","97","109","46",
    "32","79","117","114","32","111","102","102","105","99","101","32","105","115","32",
    "105","110","32","78","101","119","112","111","114","116","32","66","101","97","99",
    "104","46","32","84","104","101","32","104","111","109","101","32","111","102","102",
    "105","99","101","32","105","115","32","108","111","99","97","116","101","100","32",
    "105","110","32","76","111","110","100","111","110","44","32","85","110","105","116",
    "101","100","32","75","105","110","103","100","111","109","46","32","60","98","114",
    "32","47","62","10","60","98","114","32","47","62","10","87","101","32","114",
    "101","113","117","105","114","101","32","102","117","108","108","32","116","105","109",
    "101","32","100","101","118","101","108","111","112","101","114","115","32","116","111",
    "32","112","101","114","102","111","114","109","32","98","111","116","104","32","102",
    "114","111","110","116","32","97","110","100","32","98","97","99","107","32","101",
    "110","100","32","116","97","115","107","115","46","32","70","111","110","116","32",
    "101","110","100","32","114","101","113","117","105","114","101","115","32","80","72",
    "80","44","32","83","81","76","44","32","72","84","77","76","44","32","97",
    "110","100","32","74","97","118","97","115","99","114","105","112","116","46","32",
    "66","97","99","107","32","101","110","100","32","116","97","115","107","115","32",
    "97","114","101","32","109","111","115","116","108","121","32","80","72","80","32",
    "97","110","100","32","83","81","76","46","9","9","60","98","114","32","47",
    "62","10","60","98","114","32","47","62","10","87","101","32","110","101","101",
    "100","32","113","117","97","108","105","116","121","32","112","101","111","112","108",
    "101","32","119","104","111","32","99","97","110","32","97","100","100","32","118",
    "97","108","117","101","44","32","101","110","106","111","121","32","116","104","101",
    "32","116","111","112","105","99","32","109","97","116","116","101","114","44","32",
    "97","110","100","32","101","110","106","111","121","32","97","32","99","104","97",
    "108","108","101","110","103","101","46","60","98","114","32","47","62","10","60",
    "98","114","32","47","62","10","84","111","112","32","82","101","97","115","111",
    "110","115","32","116","111","32","87","111","114","107","32","119","105","116","104",
    "32","85","115","58","60","98","114","32","47","62","10","45","32","79","117",
    "114","32","99","111","109","112","97","110","121","32","105","115","32","119","101",
    "108","108","32","101","115","116","97","98","108","105","115","104","101","100","32",
    "119","105","116","104","32","49","53","32","121","101","97","114","115","32","111",
    "102","32","104","105","115","116","111","114","121","46","60","98","114","32","47",
    "62","10","45","32","89","111","117","32","119","105","108","108","32","104","97",
    "118","101","32","116","104","101","32","99","104","97","110","99","101","32","116",
    "111","32","108","101","97","100","32","101","120","99","105","116","105","110","103",
    "32","110","101","119","32","100","101","118","101","108","111","112","109","101","110",
    "116","32","112","114","111","106","101","99","116","115","32","97","110","100","32",
    "97","100","100","32","121","111","117","114","32","111","119","110","32","109","97",
    "103","105","99","32","116","111","32","105","116","60","98","114","32","47","62",
    "10","45","32","87","101","32","97","114","101","32","97","32","108","101","97",
    "100","105","110","103","32","112","114","111","118","105","100","101","114","32","111",
    "102","32","102","105","110","97","110","99","105","97","108","32","100","97","116",
    "97","44","32","110","101","119","115","44","32","99","104","97","114","116","115",
    "44","32","97","110","100","32","111","116","104","101","114","32","116","111","111",
    "108","115","46","60","98","114","32","47","62","10","60","98","114","32","47",
    "62","10","87","104","97","116","32","89","111","117","32","87","105","108","108",
    "32","66","101","32","68","111","105","110","103","60","98","114","32","47","62",
    "10","45","32","87","111","114","107","105","110","103","32","111","110","32","111",
    "117","114","32","85","83","32","97","110","100","32","77","101","120","105","99",
    "111","32","115","105","116","101","115","60","98","114","32","47","62","10","45",
    "32","82","97","112","105","100","32","100","101","118","101","108","111","112","109",
    "101","110","116","32","97","110","100","32","100","101","112","108","111","121","109",
    "101","110","116","32","111","102","32","110","101","119","32","102","101","97","116",
    "117","114","101","115","32","97","110","100","32","102","117","110","99","116","105",
    "111","110","97","108","105","116","121","32","111","110","32","100","101","115","107",
    "116","111","112","32","97","110","100","32","109","111","98","105","108","101","32",
    "118","105","101","119","115","60","98","114","32","47","62","10","45","32","83",
    "112","101","99","105","97","108","32","80","114","111","106","101","99","116","115",
    "32","97","115","32","116","104","101","121","32","112","111","112","32","117","112",
    "60","98","114","32","47","62","10","60","98","114","32","47","62","10","87",
    "104","97","116","32","89","111","117","32","78","101","101","100","32","102","111",
    "114","32","116","104","105","115","32","80","111","115","105","116","105","111","110",
    "60","98","114","32","47","62","10","45","32","83","116","114","111","110","103",
    "32","80","114","111","103","114","97","109","109","105","110","103","32","75","110",
    "111","119","108","101","100","103","101","32","45","32","67","111","110","99","117",
    "114","114","101","110","99","121","44","32","97","108","103","111","114","105","116",
    "104","109","32","97","110","97","108","121","115","105","115","44","32","97","110",
    "100","32","100","97","116","97","98","97","115","101","32","116","114","97","110",
    "115","97","99","116","105","111","110","115","32","97","114","101","32","97","108",
    "108","32","116","111","112","105","99","115","32","121","111","117","32","115","104",
    "111","117","108","100","32","98","101","32","102","97","109","105","108","105","97",
    "114","32","119","105","116","104","46","60","98","114","32","47","62","10","45",
    "32","72","105","103","104","108","121","32","80","114","111","102","105","99","105",
    "101","110","116","32","119","105","116","104","32","80","72","80","44","32","72",
    "84","77","76","53","44","32","67","83","83","44","32","74","97","118","97",
    "83","99","114","105","112","116","47","106","81","117","101","114","121","44","32",
    "83","81","76","46","60","98","114","32","47","62","10","45","32","68","101",
    "116","97","105","108","45","79","114","105","101","110","116","101","100","44","32",
    "67","114","101","97","116","105","118","101","32","80","114","111","98","108","101",
    "109","32","83","111","108","118","101","114","46","60","98","114","32","47","62",
    "10","60","98","114","32","47","62","10","79","116","104","101","114","32","83",
    "107","105","108","108","115","32","87","101","32","86","97","108","117","101","60",
    "98","114","32","47","62","10","45","32","73","110","116","101","114","101","115",
    "116","32","105","110","32","102","105","110","97","110","99","101","32","97","110",
    "100","32","105","110","118","101","115","116","105","110","103","32","105","115","32",
    "118","101","114","121","32","104","101","108","112","102","117","108","46","60","98",
    "114","32","47","62","10","45","32","74","97","118","97","32","111","114","32",
    "80","121","116","104","111","110","46","60","98","114","32","47","62","10","45",
    "32","70","108","117","101","110","116","32","105","110","32","83","112","97","110",
    "105","115","104","32","111","114","32","70","114","101","110","99","104","46","60",
    "98","114","32","47","62","10","45","32","67","117","115","116","111","109","101",
    "114","32","83","101","114","118","105","99","101","32","69","120","112","101","114",
    "105","101","110","99","101","46","60","98","114","32","47","62","10","60","98",
    "114","32","47","62","10","65","112","112","108","105","99","97","116","105","111",
    "110","32","73","110","115","116","114","117","99","116","105","111","110","115","60",
    "98","114","32","47","62","10","45","32","83","101","110","100","32","97","110",
    "32","101","109","97","105","108","32","116","111","32","106","111","98","115","64",
    "97","100","118","102","110","46","99","111","109","46","32","80","108","101","97",
    "115","101","32","105","110","99","108","117","100","101","32","121","111","117","114",
    "32","114","101","115","117","109","101","32","97","110","100","32","114","101","108",
    "97","116","101","100","32","101","120","112","101","114","105","101","110","99","101",
    "46","60","98","114","32","47","62","10","45","32","69","109","97","105","108",
    "32","115","117","98","106","101","99","116","32","115","104","111","117","108","100",
    "32","98","101","58","32","73","32","119","97","110","116","32","116","111","32",
    "98","101","32","97","32","119","101","98","32","100","101","118","101","108","111",
    "112","101","114","33","60","98","114","32","47","62","10","45","32","87","114",
    "105","116","101","32","97","32","98","114","105","101","102","32","105","110","116",
    "114","111","100","117","99","116","105","111","110","32","116","111","32","105","110",
    "116","114","111","100","117","99","101","32","121","111","117","114","115","101","108",
    "102","32","97","110","100","32","104","105","103","104","108","105","103","104","116",
    "32","114","101","108","101","118","97","110","116","32","115","107","105","108","108",
    "115","46","60","98","114","32","47","62","10","45","32","78","111","116","101",
    "32","116","104","101","32","98","117","103","115","32","121","111","117","32","99",
    "111","114","114","101","99","116","101","100","32","105","110","32","116","104","105",
    "115","32","99","111","100","101","46","32","84","104","101","114","101","32","105",
    "115","32","97","116","32","108","101","97","115","116","32","49","32","102","97",
    "116","97","108","32","101","114","114","111","114","32","97","110","100","32","49",
    "32","108","111","103","105","99","32","101","114","114","111","114","46","60","98",
    "114","32","47","62","10","60","98","114","32","47","62","10","83","97","108",
    "97","114","121","58","32","36","54","53","44","48","48","48","46","48","48",
    "32","47","121","101","97","114","60","98","114","32","47","62","10","70","76",
    "83","65","32","67","108","97","115","115","105","102","105","99","97","116","105",
    "111","110","58","32","83","97","108","97","114","121","32","69","120","101","109",
    "112","116","60","98","114","32","47","62","10");

    $search1 = 60 . ";&#" . 98 . ";&#" . 114 . ";&#" . 32 . ";&#" . 47 . ";&#" . 62;

    $output = "";
    foreach($message as $char)
    {
    $output .= "&#" . $char . ";";
    }

    $output = str_replace($search1,"< " . "br" . " /" . ">" . " ",$output,"< " . "br" . " /" . ">" . " ");

    echo $output;

    نشون دادن <br> به این معنی که در صفحه اعمال بشه و هرجا بود به یه سطر پایین تر بره متن.
    ممنونم

    و مطلب دیگه اینکه همین کد رو یجوری درست کنم نه اینکه از CHR استفاده بخوام بکنم
    __________________________________________________________________________
    [تصویر:  iranphp.jpg]
    (آخرین ویرایش در این ارسال: ۱۳۹۵ ارديبهشت ۲۳ ۰۱:۳۳ عصر، توسط kiarash_kcm.)
    ۱۳۹۵ ارديبهشت ۲۳ ۱۲:۳۸ عصر
    یافتن ارسال‌ها WWW پاسخ با نقل قول
     تشکر شده توسط :
    Reza آفلاین
    رضا شیخله
    *****

    ارسال‌ها: 3,025
    تاریخ عضویت: ۱۳۹۰ آبان ۱۶
    اعتبار: 133
    تشکرها : 2724
    ( 2716 تشکر در 1692 ارسال )
    ارسال: #2
    RE: مشکل در کار با str_replace لطفا کمک کنید
    ببین تابع nl2br کارت رو راه نمی اندازه ؟
    والا حقیقتا من از کد شما هیچی نفهمیدم اصلا هم متوجه نشدم چکار میخواید بکنید .
    __________________________________________________________________________
    -- - RezaWorkShop.ir - blog.RezaOnline.net
    ۱۳۹۵ ارديبهشت ۲۳ ۰۷:۲۱ عصر
    یافتن ارسال‌ها WWW پاسخ با نقل قول
     تشکر شده توسط : Alaa
    kiarash_kcm آفلاین
    عضو
    ***

    ارسال‌ها: 159
    تاریخ عضویت: ۱۳۹۲ بهمن ۷
    اعتبار: 5
    تشکرها : 12
    ( 48 تشکر در 41 ارسال )
    ارسال: #3
    RE: مشکل در کار با str_replace لطفا کمک کنید
    (۱۳۹۵ ارديبهشت ۲۳ ۰۷:۲۱ عصر)Reza نوشته شده توسط:  ببین تابع nl2br کارت رو راه نمی اندازه ؟
    والا حقیقتا من از کد شما هیچی نفهمیدم اصلا هم متوجه نشدم چکار میخواید بکنید .

    سلام ممنون از توجه شما ... من مشکلم رو حل کردم با این کد .
    من ساکن ایران نیستم یه شرکتی برای استخدام کردن برنامه نویس این کد رو گذاشته بود که باگ داخل کد رو درست کنه و بعد بتونه متن استخدام رو ببینه ... که یه آرایه داره که داخلش همه متن رو با کد های اسکی ذخیره کرده من با این کد تونستم بخونمش :
    کد:
    $search1 =   "&#" . 60 .";&#" . 98 . ";&#" . 114 . ";&#" . 32 . ";&#" . 47 . ";&#" . 62 .";";
    $output="";
    foreach($message as $char)
    {
    $output .= "&#" . $char . ";";
    }
    $output=str_replace($search1,"<br />",$output);
    echo $output;
    همینطور میشد این و اینحوری هم خوند :

    کد:
    $search1 =   "&#" . 60 .";&#" . 98 . ";&#" . 114 . ";&#" . 32 . ";&#" . 47 . ";&#" . 62 .";";
    $output="";
    foreach($message as $char)
    {
    //$output .= "&#" . $char . ";";
    $output.=chr($char);
    }
    //$output = str_replace($search1,"< " . "br" . " /" . ">" . " ",$output,"< " . "br" . " /" . ">" . " ");
    //$output=str_replace($search1,"<br />",$output);
    echo $output;
    همین فقط من نمیخواستم با CHR بخونمش که کد اول رو براش نوشتم همین
    ممنون.
    __________________________________________________________________________
    [تصویر:  iranphp.jpg]
    ۱۳۹۵ ارديبهشت ۲۳ ۰۹:۰۱ عصر
    یافتن ارسال‌ها WWW پاسخ با نقل قول
     تشکر شده توسط :
    « قدیمی تر | تازه‌ تر »

    ارسال پاسخ
    پرش به انجمن:


    کاربرانِ درحال بازدید از این موضوع: 1 مهمان
    IranPHP.org | تماس با ما | بازگشت به بالا | بازگشت به محتوا | بایگانی | پیوند سایتی RSS