php-general Digest 19 Jun 2010 09:10:16 -0000 Issue 6806
php-general Digest 19 Jun 2010 09:10:16 - Issue 6806 Topics (messages 306246 through 306269): Re: stripping first comma off and everything after 306246 by: Robert Cummings 306247 by: Adam 306248 by: João Cândido de Souza Neto 306249 by: Daniel P. Brown 306263 by: shiplu 306264 by: Robert Cummings 306265 by: Troy Oltmanns 306266 by: Robert Cummings 306267 by: Adam Richardson 306268 by: Adam Richardson 306269 by: Ashley Sheridan newbie sequel question: how do we search for multiple things on 1 field like: 306250 by: Dave 306252 by: Rick Dwyer 306253 by: Daniel Brown 306256 by: Dave 306258 by: Daniel Brown Replacing Registered Symbol 306251 by: Rick Dwyer 306254 by: Bob McConnell 306255 by: Daniel Brown 306257 by: Rick Dwyer 306259 by: Daniel Brown 306260 by: Rick Dwyer 306261 by: Daniel P. Brown 306262 by: Rick Dwyer Administrivia: To subscribe to the digest, e-mail: php-general-digest-subscr...@lists.php.net To unsubscribe from the digest, e-mail: php-general-digest-unsubscr...@lists.php.net To post to the list, e-mail: php-gene...@lists.php.net -- ---BeginMessage--- Adam Williams wrote: I'm querying data and have results such as a variable named $entries[$i][dn]: CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx Basically I need to strip off the first command everything after, so that I just have it display CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92. I tried echo rtrim($entries[$i][dn],,); but that doesn't do anything. Any ideas? ?php preg_replace( '#,.*$#', '', $entries[$i]['dn'] ); ? Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s). Disclosure, copying, and distribution are prohibited unless authorized. ---End Message--- ---BeginMessage--- I'm querying data and have results such as a variable named $entries[$i][dn]: CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx Basically I need to strip off the first command everything after, so that I just have it display CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92. I tried echo rtrim($entries[$i][dn],,); but that doesn't do anything. Any ideas? ---End Message--- ---BeginMessage--- Why not this? $var = explode(,,$entries[$i][dn]); $var = $var[0]; Adam Williams adam_willi...@bellsouth.net escreveu na mensagem news:4c1bcf62.5070...@bellsouth.net... I'm querying data and have results such as a variable named $entries[$i][dn]: CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx Basically I need to strip off the first command everything after, so that I just have it display CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92. I tried echo rtrim($entries[$i][dn],,); but that doesn't do anything. Any ideas? ---End Message--- ---BeginMessage--- On Fri, Jun 18, 2010 at 15:56, Adam Williams adam_willi...@bellsouth.net wrote: I'm querying data and have results such as a variable named $entries[$i][dn]: CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx Basically I need to strip off the first command everything after, so that I just have it display CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92. I tried echo rtrim($entries[$i][dn],,); but that doesn't do anything. Any ideas? Check out substr() with strpos(). ?php $s = 'CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx'; if (substr($s,0,strpos($s,',')) == 'CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92') { echo Good..PHP_EOL; } else { echo Bad..PHP_EOL; } ? -- /Daniel P. Brown daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ We now offer SAME-DAY SETUP on a new line of servers! ---End Message--- ---BeginMessage--- I'll use, list($data) = explode(,,$entries[$i][dn]); Shiplu Mokadd.im My talks, http://talk.cmyweb.net Follow me, http://twitter.com/shiplu SUST Programmers, http://groups.google.com/group/p2psust Innovation distinguishes bet ... ... (ask Steve Jobs the rest) ---End Message--- ---BeginMessage--- shiplu wrote: I'll use, list($data) = explode(,,$entries[$i][dn]); It's probably the least efficient method. Cheers, Rob. -- E-Mail Disclaimer: Information contained in this message and any attached documents is considered confidential and legally protected. This message is intended solely for the addressee(s).
Re: [PHP] stripping first comma off and everything after
On Fri, Jun 18, 2010 at 3:56 PM, Adam Williams adam_willi...@bellsouth.netwrote: I'm querying data and have results such as a variable named $entries[$i][dn]: CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx Basically I need to strip off the first command everything after, so that I just have it display CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92. I tried echo rtrim($entries[$i][dn],,); but that doesn't do anything. Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Adam (how could I not offer feedback to one with such a distinguished first name), rtrim() removes the characters contained in the second argument, it doesn't split a string using them. I would probably use strstr() if I didn't need the other sections, or, if I needed the other sections for later, I'd use explode: $your_string = 'CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx,'; echo strstr($haystack = $your_string, $needle = ',', $before_needle = true); if ($sections = explode($delimiter = ',', $string = $your_string)) echo current($sections); Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] stripping first comma off and everything after
On Sat, Jun 19, 2010 at 3:08 AM, Adam Richardson simples...@gmail.comwrote: On Fri, Jun 18, 2010 at 3:56 PM, Adam Williams adam_willi...@bellsouth.net wrote: I'm querying data and have results such as a variable named $entries[$i][dn]: CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx Basically I need to strip off the first command everything after, so that I just have it display CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92. I tried echo rtrim($entries[$i][dn],,); but that doesn't do anything. Any ideas? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Adam (how could I not offer feedback to one with such a distinguished first name), rtrim() removes the characters contained in the second argument, it doesn't split a string using them. I would probably use strstr() if I didn't need the other sections, or, if I needed the other sections for later, I'd use explode: $your_string = 'CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx,'; echo strstr($haystack = $your_string, $needle = ',', $before_needle = true); if ($sections = explode($delimiter = ',', $string = $your_string)) echo current($sections); Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com Whoops! I realized in the explode example I had omitted the call to count (idea being if you didn't find any comma's, maybe you need to handle those situations differently): if (count($sections = explode($delimiter = ',', $string = $your_string)) 1) echo $sections[0]; Although, if it doesn't matter, you could just do: echo current(explode(',', $your_string)); And, as mentioned above, strstr() is one simple call if you won't need the other sections: echo strstr($your_string, ',' true); Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
Re: [PHP] stripping first comma off and everything after
On Fri, 2010-06-18 at 15:03 -0500, Adam wrote: I'm querying data and have results such as a variable named $entries[$i][dn]: CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx Basically I need to strip off the first command everything after, so that I just have it display CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92. I tried echo rtrim($entries[$i][dn],,); but that doesn't do anything. Any ideas? A substring() a strpos() should do the trick: substring($entries[$i]['dn'], 0, strpos($entries[$i]['dn']-1)) Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] stripping first comma off and everything after
On Sat, 2010-06-19 at 10:09 +0100, Ashley Sheridan wrote: On Fri, 2010-06-18 at 15:03 -0500, Adam wrote: I'm querying data and have results such as a variable named $entries[$i][dn]: CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92,OU=XXf,OU=XX,OU=X,DC=,DC=xx,DC=xxx Basically I need to strip off the first command everything after, so that I just have it display CN=NTPRTPS3-LANIER-LD335c-LH107-PPRNP9A92. I tried echo rtrim($entries[$i][dn],,); but that doesn't do anything. Any ideas? A substring() a strpos() should do the trick: substring($entries[$i]['dn'], 0, strpos($entries[$i]['dn']-1)) Thanks, Ash http://www.ashleysheridan.co.uk An amendment, as I read the rest of the thread and realised that I too had missed out a check for the comma: substring($entries[$i]['dn'], 0, (strpos($entries[$i]['dn']?strpos($entries[$i]['dn']-1:strlen($entries[$i]['dn'] It doesn't look pretty, but it should do the trick. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] stripping first comma off and everything after
On Sat, Jun 19, 2010 at 05:09, Ashley Sheridan a...@ashleysheridan.co.uk wrote: A substring() a strpos() should do the trick: Echo echo [sprintf()] -- /Daniel P. Brown URGENT: EXTENDED TO SATURDAY, 19 JUNE: $100 OFF YOUR FIRST MONTH, FREE CPANEL FOR LIFE ON ANY NEW DEDICATED SERVER. NO LIMIT! daniel.br...@parasane.net || danbr...@php.net http://www.parasane.net/ || http://www.pilotpig.net/ We now offer SAME-DAY SETUP on a new line of servers! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What am I missing here?
Hello List. I am completely at a loss for why the line of code below returns the desired value: $PATH_INFO= substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRI PT_NAME']), strlen($_SERVER['REQUEST_URI'])); BUT, putting the same line of code on 1 line fails to return anything: $PATH_INFO= substr($_SERVER['REQUEST_URI'],strlen($_SERVER['SCRIPT_NAME']), strlen($_SERVER['REQUEST_URI'])); --Rick -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] stripping first comma off and everything after
On 6/19/2010 3:08 AM, Adam Richardson wrote: $before_needle = true Requires 5.3 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php