Jump to content

NaGGi

Members
  • Posts

    24
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

NaGGi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Got it: if ( preg_match('/^.*Matkahuolto.*$/',$shipping_rate_id)) {
  2. Uhm I'm a bit noob with PHP so how that should be coded there? Like if I just wanna check if that word 'Matkahuolto' is in that $shippin_rate_id variable it would echo something? Edit: Guess this works if those end numbers change: if ( preg_match('/standard_shipping%7CMatkahuolto%7CMatkahuolto%7C....%7C./',$shipping_rate_id)) { Looks crappy though.
  3. I have following if statement: if ( '$shipping_rate_id' == 'standard_shipping%7CMatkahuolto%7CMatkahuolto%7C6.90%7C3') { Numbers in the end of that mess can change though and I'd like to write the if statement so that the numbers can change without giving problems. So is it possible to add regexp in there somehow? Or any other ideas how to code it?
  4. Ok thanks a lot! Gotta check that loop out if I need it.
  5. Oh this simple thing actually works. That [0] tells that there is array in array or why it works? Problem comes when there is bigger array like [1],[2], etc though.
  6. That gives an warning and not_found result Warning: Wrong parameter count for in_array() in ... not_found
  7. Looked all search results but didnt quite found what I was looking for and my noob php brain can't figure the php manual out so I'll just ask. I have an array which have another array inside and Id like to searh a value from that array My array: print_r($product_rows); gives: Array ( [0] => Array ( [row_color] => sectiontableentry1 [product_name] => Lattaaa pew [product_attributes] => [product_sku] => xxxx [product_price] => 45.00 € ) Now I have modifer: $db_sku = xxxx Now I'd like to search if that xxxx value is in that array How that if sentence should be written? Atm my code looks like this but its not working if (in_array(array($product_sku, $db_sku ),$product_rows) ) { echo found; } else { echo not_found; } Any hints?
  8. Your code was OK if I would be interested in the results only but I was trying to learn something here and your latest code is actually first ok answer for my question Interesting way to do it. Now I just have to understand why it works heh.
  9. That definately works but now its not inside foreach anymore Main question is: Can it be done inside foreach?
  10. That break doesnt still solve the problem and you already said why. It sill prints that element 1 from the array. It breaks when it gets to that element 2 leaving the 3th out though problem seems to be that it still reads this part for element 0 and 1 even if there is 'Matkahuolto' elseif( $k > 0 && $k < 4) { echo $v.'; '; } 0 is left out leaving element 1 and 2 then break -> Matkahuolto;Rahti vapaa Maybe this is just not possible to do like I'm trying?
  11. Yes, I want it to print only 'Rahti vapaa' and nothing else if there is 'Matkahuolto' in the array but it should print it normally if there is something else than 'Matkahuolto'. But I start to see now why it doesnt do that and dunno if that can be done inside foreach and that is really my question. Can it be done inside foreach? One more clarification what I want to see: Case 1 $rate_details array = 0 = standard shipping 1 = Matkahuolto 2 = Matkahuolto 3 = 5.90 4 = 22 Case 1 Result: Rahti Vapaa Case 2 $rate_details array = 0 = standard shipping 1 = DPS 2 = DPS 3 = 5.90 4 = 22 Case 2 Result: DPS; DPS; 5.90€
  12. Yes I can see that it echoes out both if and else part but why it does that? How that should be coded to to get out only 'Rahti vapaa' when there is 'Matkahuolto' in the array? It should echo the else part if there is something else than 'Matkahuolto' in the array.
  13. Ok new day and new strenght Yeah I did forget something when I recreated the problem global $total Before that if sentence and that if sentence didnt work at all. Now I get the results which I find weird (double quotes or not) which is: Matkahuolto; Rahti vapaa5.90€; So that if sentece is true but it still mixes it with the else statement too. Normally: Matkahuolto; Matkahuolto;5.90€; after adding if statement Matkahuolto; Rahti vapaa5.90€; I want it to give only 'Rahti vapaa' when that if statement is true. Why its not working? The $rate_details array is this: 0 = standard shipping 1 = Matkahuolto 2 = Matkahuolto 3 = 5.90 4 = 22
  14. Aint that exactly the same code I have been trying? Well didnt do anything. Guess that 'if ($k == 2...' doesnt work now.
  15. It gives: Matkahuolto; Matkahuolto; 5.90€; For some reason it doesnt give out what it did previously. Maybe some cache thing. Dunno but it gave out: Matkahuolto; Rahti vapaa; 5.90€; But I want it to give out just 'Rahti vapaa' when foreach founds out 'Matkahuolto' from that $rate_details array. If there is something else than 'Matkahuolto' in the array it would normally give out what it does now. Is this possible with one foreach?
×
×
  • 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.