Re: VB to PHP

From: Date: Mon, 26 Jun 2000 03:17:14 +0000
Subject: Re: VB to PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-3066@lists.php.net to get a copy of this message
On 26 Jun, Kasper (Swebase Network) wrote: > Hello i have a real problem and i need help > > I wonder if this VB string can be replaces whit PHP, and if it can can anyone send me how to?? > > > > ***************************************************** > sT = Trim(sProductId) > sU = "" > For iI = 1 To Len(sT) > iC = Asc(Mid$(sT, iI, 1)) > sU = sU + Chr$(iC Xor &HFF) > Next iI > VNnilRec.ProdId = sU > > ******************************************************** > > > /kasper Seems simple enough; trim leading and trailing spaces from string var sProductId. The PHP equivalent is chop(). Then loop through the string, xoring (presumably that's it - can't find it in VB4 refs) each character with hex FF and appending the result to string var sU You can access each character in a string as an array element; so if the string $s contains hello then: $s[0] = h $s[1] = e and so forth. The PHP xor operator is the caret ^ That should give you enough information to be able to dod what you want. Cheers -- David Robley | WEBMASTER & Mail List Admin RESEARCH CENTRE FOR INJURY STUDIES | http://www.nisu.flinders.edu.au/ AusEinet | http://auseinet.flinders.edu.au/ Flinders University, ADELAIDE, SOUTH AUSTRALIA

« previous php.general (#3066) next »