Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> explode?
sneewee
post
Post #1





Grupa: Zarejestrowani
Postów: 3
Pomógł: 0
Dołączył: 14.05.2003
Skąd: Kraków

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


Mam pewne pytanie...

nie moge znalezc w manualach ani nigdzie indziej, jak zrobic cos takiego..


input:

$string = "sKryPt testowy";

output:

$tablica[0] = "s";
$tablica[1] = "K";
$tablica[2] = "r";
$tablica[3] = "y";
$tablica[4] = "P";
$tablica[5] = "t";

---------

funkcja explode dzieli wylacznie po znakach, jak wiec podzielic tekst NA ZNAKI?


Pozdrawiam,
marcin at leliwa dot com
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
DeyV
post
Post #2





Grupa: Zarząd
Postów: 2 277
Pomógł: 6
Dołączył: 27.12.2002
Skąd: Wołów/Wrocław




Jeszcze ciekawiej będzie w PHP5 - tam zostanie to zróżnicowane.
Cytat
a) There is an ambiguity in today’s sharing of array offsets syntax for both strings
and arrays. In code such as $str[0] = ‘a’; where $str is an empty string (due to
earlier php 4 and php 3 behavior) $str is treated as an array and therefore the
above statement would result in $str[0] being converted to an array and having its
offset 0 being set to the string “a”. However, some people would expect the result
to be $str as the string value “a”.
(IMG:http://forum.php.pl/style_emoticons/default/cool.gif) By introducing a specialized syntax for string offsets it will be possible to
somewhat optimize the run-time processing, as we will know at compile-time that
the user specifically means to use a string offset.
c) Language wise it is much better if developers will be able to tell if the author
meant to use array offsets or string offsets in a code snippet.

Cytat
Functionality
The currently suggested syntax is as follows:
$str{2} = ‘a’;
An example of the new functionality:
$str1 = $str2 = “”;
$str1{0} = ‘a’;
$str2[0] = ‘a’;
The result will be $str1 being the string “a” and $str2 being array(0 => “a”).
Go to the top of the page
+Quote Post

Posty w temacie


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: 26.12.2025 - 10:36