[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



(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:

&gt; Is there a way to say &quot;Just give me the first n characters of a string&quot; 
&gt; in PHP?  For example, if the string was &quot;johndoe&quot;, and I just wanted the 
&gt; first 3 characters, or &quot;joh&quot;?  I think I could do it with some kind of 
&gt; regex, but I can't seem to come up with one that works.  It will be used 
&gt; in a MySQL query when it's done, like the following:
&gt; 
&gt; $string = &quot;johndoe&quot;;
&gt; $newstring = justgivemetheleft3($string);
&gt; 
&gt; $query = &quot;SELECT * from table where name like &quot;$newstring%&quot;
&gt; 
&gt; I can't say give me everything that matches johndoe, because some of 
&gt; them are john doe, some are john_doe, some are john, etc.  But, the 
&gt; first 3 will always be right.
&gt; _______________________________________________
&gt; Ale mailing list
&gt; Ale at ale.org
&gt; <a  rel="nofollow" href="http://www.ale.org/mailman/listinfo/ale";>http://www.ale.org/mailman/listinfo/ale</a>
&gt; 
&gt; 

-- 
Jenn Taylor
jtaylor at onlinea.com


</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00570" href="msg00570.html">[ale] [OT] PHP Question</a></strong>
<ul><li><em>From:</em> lists at cybertechcafe.net (Nathan J. Underwood)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00567" href="msg00567.html">[ale] [OT] PHP Question</a></strong>
<ul><li><em>From:</em> lists at cybertechcafe.net (Nathan J. Underwood)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00567.html">[ale] [OT] PHP Question</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00569.html">[ale] [OT] PHP Question</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00567.html">[ale] [OT] PHP Question</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00570.html">[ale] [OT] PHP Question</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00568"><strong>Date</strong></a></li>
<li><a href="threads.html#00568"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>

<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>