Jump to content

xiaix

Members
  • Posts

    14
  • Joined

  • Last visited

    Never

About xiaix

  • Birthday 07/16/1973

Contact Methods

  • AIM
    GC+Xiaix
  • Website URL
    http://www.xiaix.com

Profile Information

  • Gender
    Male
  • Location
    Ohio

xiaix's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yep, that works great. It's better than what I was starting to do... $a = "abcDEF"; $b = "abcDEF"; $lenA = strlen($a); $lenB = strlen($b); if ($lenA != $lenB) { echo "Diff Len, no need to continue."; exit(); } $data1 = preg_split("//", $a); $data2 = preg_split("//", $b); $len = $lenA; $found = 0; for ($x = 1; $x <= $len; $x++) { $found = 0; for ($y = 1; $y <= $len; $y++) { if ($data1[$x] == $data1[$y]) { $found = 1; break; } } if ($found == 0) break; } if ($found == 0) echo "No match"; Which wasn't quite working anyway.
  2. Best method to for the following? // The following $str1 and $str2 should say they are identical $str1 = "abcDEF"; $str2 = "EcFabD"; // The following $str1 and $str2 should say they are NOT identical because of the "a" "A" case difference. $str1 = "abcDEF"; $str2 = "EcFAbD"; I'm comparing bitvector strings. "ABC" is different than "abc". "abc" is the same as "cba". What's the best php function or method I should use? Thank you.
  3. *update* <pre> tags got messy, and after much trying to get things to pad correctly, I gave up and opted for table/row/columns to handle my text padding/justification issues. Everything works great now. Example: // Let's list armor defenses if ($howManyArmorDef>0) { $part .= sprintf("<BR /><strong>Defenses</strong><BR />"); $part .= sprintf("<table>"); if ($data1["e"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["e"], $defType["e"]); } if ($data1["f"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["f"], $defType["f"]); } if ($data1["g"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["g"], $defType["g"]); } if ($data1["h"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["h"], $defType["h"]); } if ($data1["i"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["i"], $defType["i"]); } if ($data1["j"] > 0) { $part .= sprintf("<tr><td>%+d</td><td>[%s]</td></tr>", $data1["j"], $defType["j"]); } $part .= sprintf("</table>"); }
  4. Ah, gotcha. I was scratching my head for hours as to why it wouldn't work. Didn't know that HTML wouldn't display padding like that. I'll use your advise with the <pre / > tags. Thanks for the quick response.
  5. This code: if ($data1["e"] > 0) { $part .= sprintf("<strong>%s %d %s</strong>", $data1["e"] > 0 ? "+":"-", $data1["e"], $defType["e"]); if ($howManyArmorDef > ($e1 += 1)) { $part .= "<BR />"; }} Displays this: +54 Melee Piercing Defense Fine, but if I use this code (notice the %5s): if ($data1["e"] > 0) { $part .= sprintf("<strong>%s %d %5s</strong>", $data1["e"] > 0 ? "+":"-", $data1["e"], $defType["e"]); if ($howManyArmorDef > ($e1 += 1)) { $part .= "<BR />"; }} I still get this: +54 Melee Piercing Defense But I should get this: +54 Melee Piercing Defense What gives? What am I doing wrong? Thanks.
  6. You, my friend, are genius. Worked wonderfully. Thank you.
  7. Thank you for your very quick reply. I could see str_split() working like I needed if my string were a one-to-one ratio, like: a4b2c5 But will str_split() still work the way I need it to if my string is: a4b24854c555 ?
  8. I have a string coming in from a database. For example: a0b34c7d0e2333 What I would like to do is build an end result keyed array with that string, like this: $dataArray = array("a" => "0", "b" => "34", "c" => "7", "d" => "0", "e" => "2333"); Since I don't have a valid delimiter for the explode function to work, I would like to know if I can use the letters (alpha) of the incoming string as a delimiter. What coding hurdles would I need to convert my incoming string into that keyed array? Is it even possible to do this? I thank you for your time and review.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.