V
V
viktorulyushev2017-02-06 11:29:46
PHP
viktorulyushev, 2017-02-06 11:29:46

Bitrix.Replacing a piece of code via str_replace?

In this piece of code

<label><?=$arQuestion["CAPTION"]?>
<?if ($arQuestion["REQUIRED"] == "Y"):?><?=$arResult["REQUIRED_SIGN"];?><?endif;?></label>

<?=$arQuestion["HTML_CODE"]?>

This code is generated
<label>Как к вам обращаться?     <font color='red'><span class='form-required starrequired'>*</span></font></label>

<input type="text"  class="inputtext"  name="form_text_4" value="" size="0" />

Bitrix itself forms them somehow, a search throughout the project did not return anything, only in css files there is a mention of these classes, in general, you need to replace font with span and size = "0" with size = "1" through str_replace
I don’t understand php so i'm looking for help

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Romanov, 2017-02-06
@viktorulyushev

Yes, you can, like this:

<?
  ob_start();
?>
<label><?=$arQuestion["CAPTION"]?><?if ($arQuestion["REQUIRED"] == "Y"):?><?=$arResult["REQUIRED_SIGN"];?><?endif;?></label>
<?
  $label = ob_get_contents();
  ob_end_clean();
?>

Next, apply the str_replace function to the $label variable and print to the screen.

V
viktorulyushev, 2017-02-06
@viktorulyushev

<?
  ob_start();
?>
 <label><?=$arQuestion["CAPTION"]?>
    <?if ($arQuestion["REQUIRED"] == "Y"):?><?=$arResult["REQUIRED_SIGN"];?><?endif;?>
</label>
<?
  $label = ob_get_contents();
  ob_end_clean();
?>
<?
echo $str = str_replace("font color='red'", "span", $label);
echo $str = str_replace("/font", "/span", $str);
?>

Outputs like this, the first label is /font in the second everything is fine
<label>Как к вам обращаться?		<span><span class='form-required starrequired'>*</span></font></label>
 <label>Как к вам обращаться?		<span><span class='form-required starrequired'>*</span></span></label>

Need so
<label>Как к вам обращаться?<span><span class='form-required starrequired'>*</span></span></label>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question