Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> substr i obciecie ostatniego znaku
kirkor0
post 23.08.2006, 19:56:37
Post #1





Grupa: Zarejestrowani
Postów: 80
Pomógł: 0
Dołączył: 18.04.2004

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


Jak za pomoca substr pobrac caly ciag znakow bez ostatniego? Od razu zaznaczam, ze nie chce uzyc strlen()!


--------------------
Bez podpisu! :P
Go to the top of the page
+Quote Post
=kokos=
post 23.08.2006, 19:59:16
Post #2





Grupa: Zarejestrowani
Postów: 114
Pomógł: 0
Dołączył: 6.08.2006

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


  1. <?php
  2. $fraza_bez_ostatniego_znaku = substr($fraza, 0, -1);
  3. ?>


--------------------
Początkujący
Go to the top of the page
+Quote Post
mls
post 23.08.2006, 19:59:49
Post #3





Grupa: Zarejestrowani
Postów: 677
Pomógł: 89
Dołączył: 31.08.2003
Skąd: Warszawa

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


  1. <?php
  2. $tekst = substr($tekst, 0, -1);
  3. ?>

a na przyszłość: substr" title="Zobacz w manualu php" target="_manual


--------------------
Go to the top of the page
+Quote Post
Cysiaczek
post 23.08.2006, 20:00:45
Post #4





Grupa: Moderatorzy
Postów: 4 465
Pomógł: 137
Dołączył: 26.03.2004
Skąd: Gorzów Wlkp.




  1. <?php
  2. substr($string, 0, -1);
  3. ?>


Ten post edytował Cysiaczek 23.08.2006, 20:01:05


--------------------
To think for yourself you must question authority and
learn how to put yourself in a state of vulnerable, open-mindedness;
chaotic, confused, vulnerability, to inform yourself.
Think for yourself. Question authority.
Go to the top of the page
+Quote Post
kirkor0
post 23.08.2006, 20:14:55
Post #5





Grupa: Zarejestrowani
Postów: 80
Pomógł: 0
Dołączył: 18.04.2004

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


Spoko, patrzylem w manualu, ale po przykladach nie zalapalem jak to zrobic w moim przypadku, bo nie zauważyłem tych na dole.
Sorka za OT.

I ja bym usunal niepotrzebne odpowiedzi.

Ten post edytował kirkor0 23.08.2006, 20:19:52


--------------------
Bez podpisu! :P
Go to the top of the page
+Quote Post
php programmer
post 23.08.2006, 20:46:11
Post #6





Grupa: Zarejestrowani
Postów: 1 045
Pomógł: 5
Dołączył: 8.11.2004
Skąd: trójmiasto

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


o kurcze, a ja się cały czas męczyłem z takim czymś:

  1. <?php
  2. substr($string, 0, strlen($string)-2);
  3. ?>
Go to the top of the page
+Quote Post
rybosom
post 20.01.2015, 17:08:29
Post #7





Grupa: Zarejestrowani
Postów: 82
Pomógł: 0
Dołączył: 6.09.2004

Ostrzeżenie: (20%)
X----


podłączę się do wątku zamiast tworzyć nowy bo w sumie temat podobny, który z poniższych sposobów jest najbardziej optymalny jeśli chodzi o obcinanie tekstu do określonego znaku?

  1. <?
  2. $atrybuty = 'tak';
  3. $link = 'http://www.wp.pl/index.php?aaa=1&bbb=2&ccc=3';
  4.  
  5. // sposób #1
  6. if ($atrybuty == "tak") {
  7. $link1 = substr($link, 0, strpos($link, '&'));
  8. } else {
  9. $link1 = substr($link, 0, strpos($link, '?'));
  10. }
  11.  
  12. // sposób #2
  13. $link2 = ($atrybuty == 'tak') ? substr($link, 0, strpos($link, '&')) : substr($link, 0, strpos($link, '?'));
  14.  
  15. // sposób #3
  16. $link3 = ($atrybuty == 'tak') ? strtok($link, '&') : strtok($link, '?');
  17. //
  18.  
  19. echo $link1 . '<br>';
  20. echo $link2 . '<br>';
  21. echo $link3;
  22. ?>
Go to the top of the page
+Quote Post
StevDefs
post 24.08.2019, 00:20:49
Post #8





Grupa: Zarejestrowani
Postów: 51
Pomógł: 0
Dołączył: 22.08.2019

Ostrzeżenie: (10%)
X----


Cialis Venta En Farmacias Buy Super Active Viagra Online Free viagra Nolvadex Dosage For Epistane

Onljne Pharmacies Buy Prednisone Online Now Cialis Flussig Kaufen where to buy cialis online safely Where To Purchase Bentyl Direct Overnight Shipping Visa Accepted Commande Cialis En France

Viagra Fast No Prescription Required Viagra Achat 10 Pilule cialis viagra levitra kaufen rezeptfrei Cialis E Fegato

Priligy Dapoxetina Prezzo viagra Precio Kamagra Viagra Generika Aus Der Apotheke
Go to the top of the page
+Quote Post

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

 



RSS Wersja Lo-Fi Aktualny czas: 24.04.2024 - 12:05