Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7390
| From | Salvatore <sal@yojimbo.hack.invalid> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: Beginner's trouble with substr |
| Date | 2012-10-29 19:46 +0000 |
| Organization | Yojimbo NNTP server |
| Message-ID | <k6mme1$2p3s$1@yojimbo.hack> (permalink) |
| References | <c67eb83e-13d8-4263-b723-a10744fcd444@googlegroups.com> <k6memb$2m6u$1@news.tokachu.com> <dac4b066-b564-4628-9be8-0fdaebb78424@ib4g2000vbb.googlegroups.com> |
On 2012-10-29, C <wrong.address.1@gmail.com> wrote: > I took that code out which defines $found. The code is trying to avoid > some nasty visitors. Ah, okay. I tried all the substr() calls and they appear to work properly. However, the second substr() call is taking the last six characters off the end of the string "$host", and not the first six characters as I imagine you are trying to do. Here's some sample code I put together to test this: <?php $host = 'a1b2c3d4e5f6'; $sub = substr($host, 6); print "$sub\n"; ?> The above code results in the string "d4e5f6" being printed out, and not "a1b2c3" as you may expect. If you want only the first six characters, set the second parameter to 0 (zero) and the third parameter to 6. -- Blah blah bleh... GCS/CM d(-)@>-- s+:- !a C++$ UBL++++$ L+$ W+++$ w M++ Y++ b++
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Beginner's trouble with substr wrong.address.1@gmail.com - 2012-10-29 10:20 -0700
Re: Beginner's trouble with substr Salvatore <sal@yojimbo.hack.invalid> - 2012-10-29 17:34 +0000
Re: Beginner's trouble with substr C <wrong.address.1@gmail.com> - 2012-10-29 10:40 -0700
Re: Beginner's trouble with substr Salvatore <sal@yojimbo.hack.invalid> - 2012-10-29 19:46 +0000
Re: Beginner's trouble with substr C <wrong.address.1@gmail.com> - 2012-10-29 22:18 -0700
Re: Beginner's trouble with substr Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-29 22:47 +0000
Re: Beginner's trouble with substr C <wrong.address.1@gmail.com> - 2012-10-29 22:21 -0700
Re: Beginner's trouble with substr Denis McMahon <denismfmcmahon@gmail.com> - 2012-10-29 23:17 +0000
Re: Beginner's trouble with substr C <wrong.address.1@gmail.com> - 2012-10-29 22:30 -0700
Re: Beginner's trouble with substr Doug Miller <doug_at_milmac_dot_com@example.com> - 2012-10-29 20:44 +0000
Re: Beginner's trouble with substr C <wrong.address.1@gmail.com> - 2012-10-29 22:19 -0700
csiph-web