[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Tue Feb 17 15:40:30 2004 -->
- <!--x-from-r13: yvfgf ng ploregrpupnsr.arg (@nguna X. Gaqrejbbq) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: Pine.LNX.4.44.0402171541550.9834-[email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] [OT] PHP Question -->
- <li><em>date</em>: Tue Feb 17 15:40:30 2004</li>
- <li><em>from</em>: lists at cybertechcafe.net (Nathan J. Underwood)</li>
- <li><em>in-reply-to</em>: <<a href="msg00568.html">[email protected]</a>></li>
- <li><em>references</em>: <<a href="msg00568.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] [OT] PHP Question</li>
J.M. Taylor wrote:
> $string = "johndoe";
> $newstring = substr($string,0,3);
>
> (take the substring of $string starting at position 0, give me 3
> characters)
>
> <a rel="nofollow" href="http://us2.php.net/manual/en/function.substr.php">http://us2.php.net/manual/en/function.substr.php</a>
>
> hth
> jenn
>
> On Tue, 17 Feb 2004, Nathan J. Underwood wrote:
>
>
>>Is there a way to say "Just give me the first n characters of a string"
>>in PHP? For example, if the string was "johndoe", and I just wanted the
>>first 3 characters, or "joh"? I think I could do it with some kind of
>>regex, but I can't seem to come up with one that works. It will be used
>>in a MySQL query when it's done, like the following:
>>
>>$string = "johndoe";
>>$newstring = justgivemetheleft3($string);
>>
>>$query = "SELECT * from table where name like "$newstring%"
>>
>>I can't say give me everything that matches johndoe, because some of
>>them are john doe, some are john_doe, some are john, etc. But, the
>>first 3 will always be right.
>>_______________________________________________
>>Ale mailing list
>>Ale at ale.org
>><a rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale">http://www.ale.org/mailman/listinfo/ale</a>
>>
>>
>
>
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00568" href="msg00568.html">[ale] [OT] PHP Question</a></strong>
<ul><li><em>From:</em> jtaylor at onlinea.com (J.M. Taylor)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00569.html">[ale] [OT] PHP Question</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00571.html">[ale] ALE NW meeting Thursday</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00568.html">[ale] [OT] PHP Question</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00569.html">[ale] [OT] PHP Question</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00570"><strong>Date</strong></a></li>
<li><a href="threads.html#00570"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>