dhernando Posted July 11, 2010 Share Posted July 11, 2010 Hi Guys, This is my first post and I need some help :-\ I want to post this to see if anyone can help me, I need to convert a php function into vb.net or C# but I have no idea, here's the function: echo spin('{an {option|choice|right}|the basic} element {more|another|else}'); function spin($s){ preg_match('#\{(.+?)\}#is',$s,$m); if(empty($m)) return $s; $t = $m[1]; if(strpos($t,'{')!==false){ $t = substr($t, strrpos($t,'{') + 1); } $parts = explode("|", $t); $s = preg_replace("+\{".preg_quote($t)."\}+is", $parts[array_rand($parts)], $s, 1); return spin($s); } I don't mind to move the question to a type of project(to paid you) if you know the answer. Thanks, Diego Link to comment https://forums.phpfreaks.com/topic/207392-php-code-to-vbnet-or-c/ Share on other sites More sharing options...
Tazerenix Posted July 23, 2010 Share Posted July 23, 2010 well C# has a RegExp library and string functions that act much like strpos() (.indexAt() i think, or .indexOf()) etc. You can also use the split function on a string object in C# much like you use the explode function: string astring = "RAWR|RAWR"; string[] pieces = pieces.Split(new string[] { "|" }, StringSplitOptions.None) will result in pieces containing the different elements corresponding to the astring string. This should get you started Link to comment https://forums.phpfreaks.com/topic/207392-php-code-to-vbnet-or-c/#findComment-1090461 Share on other sites More sharing options...
dhernando Posted July 24, 2010 Author Share Posted July 24, 2010 thanks, the problem was solved Link to comment https://forums.phpfreaks.com/topic/207392-php-code-to-vbnet-or-c/#findComment-1090476 Share on other sites More sharing options...
Tazerenix Posted July 24, 2010 Share Posted July 24, 2010 no problem! Link to comment https://forums.phpfreaks.com/topic/207392-php-code-to-vbnet-or-c/#findComment-1090478 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.