jimfog Posted March 9, 2015 Share Posted March 9, 2015 I want to concatenate a string with an INT...if I do that...the result is a string...for example: $int=5;'john'.$int;//this will output 'john5' I want this though: $int=5;'john'.$int;//this will output 'john'5 In other words...the integer remains an integer...no casting taking place.Is that possible? Link to comment Share on other sites More sharing options...
justsomeguy Posted March 9, 2015 Share Posted March 9, 2015 When you concatenate something to a string it becomes a string. You cannot concatenate things that are not strings. It converts the number to a string first, then concatenates that value. Link to comment Share on other sites More sharing options...
Ingolme Posted March 10, 2015 Share Posted March 10, 2015 The result of a concatenation can only be a string. A value cannot be of two different types at the same time. Perhaps an array will do what you want: array('john', 5); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now