Cannibal_Monkey Posted December 11, 2006 Share Posted December 11, 2006 Okay, I was reading a PHP book and I am up to Matching Strings to Patterns, and I have things, like C$ which is supposed to check if the last letter in a string is a C. So how do I use this? I tried putting it in the if () thing but that didn't work. So where do I put it? Quote Link to comment Share on other sites More sharing options...
trq Posted December 11, 2006 Share Posted December 11, 2006 What? You'll need to post some code or something, your post makes no sense. C$ is nothing in php. Quote Link to comment Share on other sites More sharing options...
Cannibal_Monkey Posted December 11, 2006 Author Share Posted December 11, 2006 The c$ is supposed to be plugged into something to determine if a string ends in c. I don't know what to plug it into. Quote Link to comment Share on other sites More sharing options...
trq Posted December 11, 2006 Share Posted December 11, 2006 Ah... I think your talking about regular expressions. Take a look at [url=http://php.net/preg_match]preg_match[/url]() and related functions.Surely your book also describes [i]how[/i] to use patterns. Quote Link to comment Share on other sites More sharing options...
Cannibal_Monkey Posted December 11, 2006 Author Share Posted December 11, 2006 No it hadn't said anything about that. I guess they forgot that part? Thanks :) Quote Link to comment Share on other sites More sharing options...
doni49 Posted December 11, 2006 Share Posted December 11, 2006 Check the last char of a string for a specific letter:[code]<?php$c = "This is a Test";if (substr(strtolower($c), -1)==(strtolower("t")){ echo "C ended in t";}?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.