-1

I'm using the below code to add an attribute to my gravity forms form tag. But there seems to be a problem with the "toLocaleString('en-US')" part. I assume this is a quote issue? As there's single quotes being used inside single quotes.... How can I fix this?

<?php 
add_filter( 'gform_form_tag', 'form_tag', 10, 2 );
function form_tag( $form_tag, $form ) {
    if ( $form['id'] != 1 ) {
        return $form_tag;
    }
    $form_tag = str_ireplace( "<form ", "<form oninput='loanval.value=parseInt(loan.value, 10).toLocaleString('en-US'); periodval.value=period.value;' ", $form_tag );
    return $form_tag;
}
?>
Shtarley
  • 313
  • 9
  • 22

1 Answers1

0

Use a backslash as such

"From time to \"time\"";

Backslashes are used in PHP to escape special characters within quotes. As PHP does not distinguish between strings and characters, you could also use this

'From time to "time"';

It has been answered before, here: Escaping quotation marks in PHP

Community
  • 1
  • 1