Jump to content

chrisran

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by chrisran

  1. Hi ! I'd like to count all occurences in "$thiscodestring" into a "dynamic?" array and print it out after the end of the loop, how do I assign the variablenames dynamically ? $query = "SELECT codes, status FROM table"; while ($row = mysql_fetch_assoc($result)) { $thiscodestring = $row[codes]; // looks like "a1 c2 d3 10 15 1 a1 a1"; $singlecodes = explode(" ", $thiscodestring); foreach($singlecodes as $thiscode) { $$thiscode[count] = $$thiscode[count] + 1; } } After all Mysql-Stuff is done I'd like to print out the counted codes, for example the code "a1" was found 100 times in all querys then $$a1[count] should be 100, c2 was found 15 times, then $$c2[count] should be 15 and so on. Question: How do I tell php to assign a "dynamic" variable with the name of the found string which was exploded (in this example a1, c2, d3... ) before ?! $$ does not seem to work. And how can I then print_r() the value if I dont know the name ? Thanks !
  2. Thanks for your reply mike, but it does not work this way: I wrote a small testprogram to check: $string = "NEWCU - Cust No 331351 0 -> 1"; $newcu = preg_match("/NEWCU - [^0-9]*([0-9]+) -> ([0-9]+)/",$string, $matches); $first = $matches[1]; $second = $matches[2]; echo "<BR><BR>NEWCU: $newcu ] $first -> $second<BR><BR>"; Result: NEWCU: 0 ] -> Any Idea ?
  3. Hi ! I've got a very long text like this: $var = "Blabla text text text [...] bla bla text text some weird text NEWCU - NEW Customer 0 -> 1 <br /> AMWHA - Some Description 0 -> 2 <br /> INST3 - Install Services 1 <br /> MORES - More Services 0 -> 1 <br /> bla bla bla text text text"; In my script I now have these keywords (NEWCU, AMWHA, MORES) set to 0 by default: $newcu = 0; $amwha = 0; $mores = 0; Now I'd like to set them to the value after the corresponding -> so for example NEWCU gets 1, AMWHA gets 2 and MORES gets 1. How do I preg_match that ? $newcu = preg_match("/NEWCU - [^] (.?) -&gt (.?)/",$var); <-- does not work. I'd like to grep on "NEWCU -" then skip everything until the -&gt and put the first digit before -&gt (here 0) into $newcu[1] and the digit after -&gt into $newcu[2].. Anyone an idea ? Thanks
  4. Thanks so much for the quick answer, it works like a charm. Finally :-)
  5. Hi, I'm again trying to match against html, but it works only partly. $string = "<option title='(71) (1)'>Phase71 Cluster1</option><option title='(49) (1)'>Phase49 Cluster1</option><option title='(36) (1)'>Phase36 Cluster1</option>"; What I've tried: $getteklistexp = "/title='\(.*?\)[^>]*\(.*?\)'>.*?<\/option><option/"; I cant use "<option title" because sometimes I have a id=xyz in between, therefore I try to grep on title=' and then I'd like to have an array like this: [0] = 71 [1] = 1 [2] = Phase71 Cluster1 [3] = 49 [4] = 1 [5] = Phase49 Cluster1 ... My result is: [0] => title='(71) (1)'>Phase1 Cluster1 What am I missing this time ? Thanks
  6. Thanks, that was is, it works now !
  7. $string="««« </form> </td> <td>IWantThisString<BR>"; I've tried with: $exp="/««« </form> </td> <td>(.*?)<BR>/"; But got no luck, the array is empty. Do I have to skip the spaces in some way ? Thanks Chris
×
×
  • 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.