Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php]problemy z rzutowaniem
styx
post
Post #1





Grupa: Zarejestrowani
Postów: 138
Pomógł: 3
Dołączył: 21.11.2005

Ostrzeżenie: (0%)
-----


mam taki kod:

  1. <?php
  2. $ile = (int)$html[2];
  3. ?>


zmienna $html[2] jest typu: string(8) "2"
zmienna $ile po użyciu rzutowania jest typu: int(0)

pytanie:
dlaczego rzutowanie się nie powiodło i mimo iż string był liczbą 2 to po rzutowaniu w $ile mam 0 ?
Go to the top of the page
+Quote Post
mike
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

Ostrzeżenie: (0%)
-----


Kod:
  1. <?php
  2.  
  3. $html = array("1", "2", "8");
  4.  
  5. echo $ile = (int)$html[2];
  6.  
  7. ?>
Wynik:
Kod
8

U mnie wszystko działa.
Go to the top of the page
+Quote Post
styx
post
Post #3





Grupa: Zarejestrowani
Postów: 138
Pomógł: 3
Dołączył: 21.11.2005

Ostrzeżenie: (0%)
-----


no ale u mnie nie działa ta tablica powstała w wyniku użycia explode a wczesniej została pobrana za pomocą curla z neta i zdekompresowana gzip

-moze to jakas wina czcionek?
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #4





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

Ostrzeżenie: (0%)
-----


Czcionek?(IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
daj var_dump tej tablicy po explode.
Go to the top of the page
+Quote Post
styx
post
Post #5





Grupa: Zarejestrowani
Postów: 138
Pomógł: 3
Dołączył: 21.11.2005

Ostrzeżenie: (0%)
-----


array(12) {
[0]=>
string(46) ""
[1]=>
string(5) ""
[2]=>
string(8) "2"
[3]=>
string(4) ""
[4]=>
string(35) "m_braniewo"
[5]=>
string(5) ""
[6]=>
string(3) ""
[7]=>
string(336) "xxxxxxxxxxxxxxxxxxxxxxx

braniewski
warmińsko-mazurskiexxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
[8]=>
string(3) ""
[9]=>
string(259) "xxxxxxxxxxxxxxxxxxxx
mazowieckiexxxxxxxxxxxxxxxxxxxxxxxx"
[10]=>
string(6) ""
[11]=>
string(0) ""
}

nie no bezsens totalny, wymiękam...

Ten post edytował styx 4.10.2007, 14:56:11
Go to the top of the page
+Quote Post
mike
post
Post #6





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

Ostrzeżenie: (0%)
-----


Jaką masz wersję PHP?
Może to ma wpływ, sam nie wiem :-/
Go to the top of the page
+Quote Post
styx
post
Post #7





Grupa: Zarejestrowani
Postów: 138
Pomógł: 3
Dołączył: 21.11.2005

Ostrzeżenie: (0%)
-----


php 5.1.6

próbowałem juz:
- set_type
- (int)
- +

porównywac
nawet if ('2'===$html[2]) {
cos takiego zwraca false

ok poradziłem sobie były tam tagi xml których nie było widac (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

temat mozna zamknąc
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.12.2025 - 16:32