0

Hey Guys,

I need to send an HTML email with the last 4 digits of the credit card. Everything else sends fine but must be an error in my code, probably didn't do it right can someone correct me please : )

XXXX-XXXX-XXXX-".substr{$_REQUEST['cc_number'] , -4, 4}

* Yeah I know, new to PHP so it's probably not the right way to do it. I thought this would work : /

3
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by edwinhermann
0

Almost right., the -4 needs to be -1 though.

A positive number will start from beginning of the string and return the number of characters specified, while a negative number to start from end of string.

In this case, you want to start with the last character(-1) and read 4 characters :)

0

Oh ok thanks, I tried that but I am still getting the following error:

Parse error: syntax error, unexpected '{'

Almost right., the -4 needs to be -1 though.

A positive number will start from beginning of the string and return the number of characters specified, while a negative number to start from end of string.

In this case, you want to start with the last character(-1) and read 4 characters :)

1

Ah, whoops, wrong brackets as well. Missed that on your first post :P

For functions, use standard braces ( and ).

Curly braces are for statements and function definitions.

So it should be substr($_REQUEST['cc_number'] , -1, 4)

Votes + Comments
Will is awesome, helped a bunch!
0

Thanks Will, you are a life saver! I appreciate it :)

Ah, whoops, wrong brackets as well. Missed that on your first post :P

For functions, use standard braces ( and ).

Curly braces are for statements and function definitions.

So it should be substr($_REQUEST['cc_number'] , -1, 4)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.