Re: [PHP] Explode Question
$one = array(0 ='golf', 1 = 'field'); $two = array(0 = On the golf course or in the field of clover); $array_exp = explode($one, $two); What's the desired result? array('golf' = On the golf course or in the field of clover, 'field' = On the golf course or in the field of clover)); ? Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Explode Question
The desired result is. Array ( [0] = On the; [1] = course or in the; [2] = of colver; ); I am just not sure the delimiter can be an array in the Explode function. Richard L. Buskirk -Original Message- From: Marc Guay [mailto:marc.g...@gmail.com] Sent: Tuesday, May 17, 2011 7:52 PM To: php-general@lists.php.net Subject: Re: [PHP] Explode Question $one = array(0 ='golf', 1 = 'field'); $two = array(0 = On the golf course or in the field of clover); $array_exp = explode($one, $two); What's the desired result? array('golf' = On the golf course or in the field of clover, 'field' = On the golf course or in the field of clover)); ? Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Explode Question
On 05/17/2011 07:53 PM, ad...@buskirkgraphics.com wrote: The desired result is. Array ( [0] = On the; [1] = course or in the; [2] = of colver; ); I am just not sure the delimiter can be an array in the Explode function. Richard L. Buskirk -Original Message- From: Marc Guay [mailto:marc.g...@gmail.com] Sent: Tuesday, May 17, 2011 7:52 PM To: php-general@lists.php.net Subject: Re: [PHP] Explode Question $one = array(0 ='golf', 1 = 'field'); $two = array(0 = On the golf course or in the field of clover); $array_exp = explode($one, $two); What's the desired result? array('golf' = On the golf course or in the field of clover, 'field' = On the golf course or in the field of clover)); ? Marc explode() takes three parameters; string, string, [int]. Where [int] is optional. Ex: $ipList = '192.168.1.0,192.168.1.1,192.168.1.2'; $ipList = explode(',',$ipList); Returns an array of strings: Array ( [0] = 192.168.1.0, [1] = 192.168.1.1, [2] = 192.168.1.2 ); -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Explode Question
On 05/17/2011 07:53 PM, ad...@buskirkgraphics.com wrote: The desired result is. Array ( [0] = On the; [1] = course or in the; [2] = of colver; ); I am just not sure the delimiter can be an array in the Explode function. Richard L. Buskirk -Original Message- From: Marc Guay [mailto:marc.g...@gmail.com] Sent: Tuesday, May 17, 2011 7:52 PM To: php-general@lists.php.net Subject: Re: [PHP] Explode Question $one = array(0 ='golf', 1 = 'field'); $two = array(0 = On the golf course or in the field of clover); $array_exp = explode($one, $two); What's the desired result? array('golf' = On the golf course or in the field of clover, 'field' = On the golf course or in the field of clover)); ? Marc Here's something to mess around with, to fit to your liking. ?php $one = array('golf','field'); $two = array(On the golf course or in the field of clover); $result = array_explode($one,$two); print_r($result); function array_explode($delimiters,$array) { if ( !is_array($delimiters) || !is_array($array) ) { //bail return; } $string = $array[0]; $regex = @(.implode('|',$delimiters).)@; return preg_split($regex,$string); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Explode Question
That is exactly it. Thanks James I knew it was simple just forgot how it was done. Richard L. Buskirk -Original Message- From: James Yerge [mailto:ja...@nixsecurity.org] Sent: Tuesday, May 17, 2011 8:51 PM To: ad...@buskirkgraphics.com Cc: 'Marc Guay'; php-general@lists.php.net Subject: Re: [PHP] Explode Question On 05/17/2011 07:53 PM, ad...@buskirkgraphics.com wrote: The desired result is. Array ( [0] = On the; [1] = course or in the; [2] = of colver; ); I am just not sure the delimiter can be an array in the Explode function. Richard L. Buskirk -Original Message- From: Marc Guay [mailto:marc.g...@gmail.com] Sent: Tuesday, May 17, 2011 7:52 PM To: php-general@lists.php.net Subject: Re: [PHP] Explode Question $one = array(0 ='golf', 1 = 'field'); $two = array(0 = On the golf course or in the field of clover); $array_exp = explode($one, $two); What's the desired result? array('golf' = On the golf course or in the field of clover, 'field' = On the golf course or in the field of clover)); ? Marc Here's something to mess around with, to fit to your liking. ?php $one = array('golf','field'); $two = array(On the golf course or in the field of clover); $result = array_explode($one,$two); print_r($result); function array_explode($delimiters,$array) { if ( !is_array($delimiters) || !is_array($array) ) { //bail return; } $string = $array[0]; $regex = @(.implode('|',$delimiters).)@; return preg_split($regex,$string); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Explode Question
On 05/17/2011 09:09 PM, ad...@buskirkgraphics.com wrote: That is exactly it. Thanks James I knew it was simple just forgot how it was done. Richard L. Buskirk -Original Message- From: James Yerge [mailto:ja...@nixsecurity.org] Sent: Tuesday, May 17, 2011 8:51 PM To: ad...@buskirkgraphics.com Cc: 'Marc Guay'; php-general@lists.php.net Subject: Re: [PHP] Explode Question On 05/17/2011 07:53 PM, ad...@buskirkgraphics.com wrote: The desired result is. Array ( [0] = On the; [1] = course or in the; [2] = of colver; ); I am just not sure the delimiter can be an array in the Explode function. Richard L. Buskirk -Original Message- From: Marc Guay [mailto:marc.g...@gmail.com] Sent: Tuesday, May 17, 2011 7:52 PM To: php-general@lists.php.net Subject: Re: [PHP] Explode Question $one = array(0 ='golf', 1 = 'field'); $two = array(0 = On the golf course or in the field of clover); $array_exp = explode($one, $two); What's the desired result? array('golf' = On the golf course or in the field of clover, 'field' = On the golf course or in the field of clover)); ? Marc Here's something to mess around with, to fit to your liking. ?php $one = array('golf','field'); $two = array(On the golf course or in the field of clover); $result = array_explode($one,$two); print_r($result); function array_explode($delimiters,$array) { if ( !is_array($delimiters) || !is_array($array) ) { //bail return; } $string = $array[0]; $regex = @(.implode('|',$delimiters).)@; return preg_split($regex,$string); } ? Not a problem, glad to be of help. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] explode () question
$rint1= rtrim($rintydata); echo $rint1; $rint2= explode(:, $rint1); The data starts like this (from and email, there are many) ; Time: November 9th 2003, 10:37AM - PST IP Address: xx.xx.xxx.xxx Browser Type: Opera/7.20 (Windows NT 5.1; U) [en] Referer: The problem is that when I do this ; while( $res=each($rint2) ) { echo br$res[1]br; }; the colon in Time messes things up. here is the result ; Time November 8th 2003, 07 15PM - PST IP Address xx.xx.xx.xxx Browser Type Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Referer when what I really want is ; Time - November 8th 2003, 07:15PM - PST IP - Address xx.xx.xx.xxx Browser Type - Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Referer - I can't figure out how to do an ereg that will replace just the colon in Time nor can I find a way to make explode ignore it. This may even be a completely wrong approach, any help would be appreciated. Do you first split the lines? What about a simple strpos and substr? $colon=strpos(':',$res) will get you the position of only the 1st colon. then strpos ($res, 0, $colon-1) will get you the 1st part and strpos ($res, $colon, strlen($res)) the second part. disclaimers: not tested. not guaranteed to be working. just a suggestion. check the manual to fix it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] explode () question
Malcolm mailto:[EMAIL PROTECTED] on Monday, November 10, 2003 9:13 AM said: I can't figure out how to do an ereg that will replace just the colon in Time nor can I find a way to make explode ignore it. This may even be a completely wrong approach, any help would be appreciated. What you'll probably want to do is write a regex that changes the colon you're trying to separate on into something else. Go from: Time: ... Other Thing: ... Different: ... To: Time% ... Other Thing% ... Different% ... After you've done this you can easily explode() based on the %. I'm not very good with regex's off the top of my head so I suggest you get The Regex Coach (easily found via google) and experiment. Chris. -- Don't like reformatting your Outlook replies? Now there's relief! http://home.in.tum.de/~jain/software/outlook-quotefix/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] explode () question
(after more and more discussion, this will be my first non-top post) $rint1= rtrim($rintydata); echo $rint1; $rint2= explode(:, $rint1); The data starts like this (from and email, there are many) ; Time: November 9th 2003, 10:37AM - PST IP Address: xx.xx.xxx.xxx Browser Type: Opera/7.20 (Windows NT 5.1; U) [en] Referer: The problem is that when I do this ; while( $res=each($rint2) ) { echo br$res[1]br; }; the colon in Time messes things up. here is the result ; Time November 8th 2003, 07 15PM - PST IP Address xx.xx.xx.xxx Browser Type Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Referer when what I really want is ; Time - November 8th 2003, 07:15PM - PST IP - Address xx.xx.xx.xxx Browser Type - Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Referer - I'd try something like: 1 ?php 2 $String = 'From: Wouter van Vliet [EMAIL PROTECTED]'; 3 preg_match('/^\s*([^:]*)\s*:\s*(.*)$/', $String, $Matches); 4 5 print_r($Matches); 6 7 ? == OUTPUT: Array ( [0] = From: Wouter van Vliet [EMAIL PROTECTED] [1] = From [2] = Wouter van Vliet [EMAIL PROTECTED] ) From here you'd be able to manipulate the things you want in any format you'd want it to have. Or use preg_match_all() if you have all mail headers in one variable. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] explode () question
Thanks to everyone who replied. I have taken the short route and changed the source data. I should have thought of that first I suppose. Now I have a few existing records to edit but from now on I'll be automagic. On Mon, 10 Nov 2003 19:00:52 +0100, Wouter Van Vliet [EMAIL PROTECTED] wrote: (after more and more discussion, this will be my first non-top post) $rint1= rtrim($rintydata); echo $rint1; $rint2= explode(:, $rint1); The data starts like this (from and email, there are many) ; Time: November 9th 2003, 10:37AM - PST IP Address: xx.xx.xxx.xxx Browser Type: Opera/7.20 (Windows NT 5.1; U) [en] Referer: The problem is that when I do this ; while( $res=each($rint2) ) { echo br$res[1]br; }; the colon in Time messes things up. here is the result ; Time November 8th 2003, 07 15PM - PST IP Address xx.xx.xx.xxx Browser Type Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Referer when what I really want is ; Time - November 8th 2003, 07:15PM - PST IP - Address xx.xx.xx.xxx Browser Type - Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) Referer - I'd try something like: 1 ?php 2 $String = 'From: Wouter van Vliet [EMAIL PROTECTED]'; 3 preg_match('/^\s*([^:]*)\s*:\s*(.*)$/', $String, $Matches); 4 5 print_r($Matches); 6 7 ? == OUTPUT: Array ( [0] = From: Wouter van Vliet [EMAIL PROTECTED] [1] = From [2] = Wouter van Vliet [EMAIL PROTECTED] ) From here you'd be able to manipulate the things you want in any format you'd want it to have. Or use preg_match_all() if you have all mail headers in one variable. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] explode question
Rol wrote: Hello all, I would like to check some names ( @ seperated strings) with this global $PHP_AUTH_USER I first do $arrLoginName = explode("@", $row-usr_loginName); How can I construct a loop which stops and returns true if a match is found? Any hints would be great. Many thanks Roland This will do it: $dim = sizeof($arrLoginName); for ($nr = 0; $nr $dim; $nr++) { if (match) { return 1; } } Greetings, Jason -- Jason Murray Developer http://www.jwebmedia.com/ 1 877 525 jWEB -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] explode question
?php function check() { $arrLoginName = explode("@", $row-usr_loginName); foreach($arrLoginName as $pos = $val) if (match) return 1; return ; } ? is this what you mean? please post regarding. -- Chris Lee Mediawaveonline.com ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 [EMAIL PROTECTED] ""Rol"" [EMAIL PROTECTED] wrote in message 002301c0a726$615218e0$[EMAIL PROTECTED]">news:002301c0a726$615218e0$[EMAIL PROTECTED]... Hello all, I would like to check some names ( @ seperated strings) with this global $PHP_AUTH_USER I first do $arrLoginName = explode("@", $row-usr_loginName); How can I construct a loop which stops and returns true if a match is found? Any hints would be great. Many thanks Roland