 |
|
 |
|
Next: Dynamic search with checkboxes
|
| Author |
Message |
External

Since: Jan 22, 2008 Posts: 9
|
(Msg. 1) Posted: Mon Oct 16, 2006 4:07 am
Post subject: Query on explode() Archived from groups: comp>lang>php (more info?)
|
|
|
Hi All,
Have a look at the following code
$test = explode('-','one-two-three-four-five');
print_r($test);
Output:
Array
(
[0] => one
[1] => two
[2] => three
[3] => four
[4] => five
)
But What I need is
Array
(
[one] => one
[two] => two
[three] => three
[four] => four
[five] => five
)
Any Help Please........
regards
moses >> Stay informed about: Query on explode() |
|
| Back to top |
|
 |  |
External

Since: Oct 16, 2006 Posts: 8
|
(Msg. 2) Posted: Mon Oct 16, 2006 6:01 am
Post subject: Re: Query on explode() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Try this one, this will work :
---------------------------------------------------
$test = explode('-','one-two-three-four-five');
$view = new Array();
foreach($test as $boo => $foo){
$view[$boo] = $foo;
}
print_r($view);
------------------------------------------------------
For php/ajax/javascript tutorials and tips, visit me on my blog at
http://www.nurazije.co.nr >> Stay informed about: Query on explode() |
|
| Back to top |
|
 |  |
External

Since: Oct 16, 2006 Posts: 8
|
(Msg. 3) Posted: Mon Oct 16, 2006 7:08 am
Post subject: Re: Query on explode() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Try this one, this will work :
---------------------------------------------------
$test = explode('-','one-two-three-four-five');
$view = new Array();
foreach($test as $boo => $foo){
$view[$foo] = $foo; // typing error, do it like this
}
print_r($view);
------------------------------------------------------
For php/ajax/javascript tutorials and tips, visit me on my blog at
http://www.nurazije.co.nr >> Stay informed about: Query on explode() |
|
| Back to top |
|
 |  |
External

Since: Jul 06, 2004 Posts: 36
|
(Msg. 4) Posted: Mon Oct 16, 2006 1:19 pm
Post subject: Re: Query on explode() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Oct 03, 2006 Posts: 45
|
(Msg. 5) Posted: Mon Oct 16, 2006 3:20 pm
Post subject: Re: Query on explode() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hmm NurAzije wrote:
> Try this one, this will work :
> ---------------------------------------------------
> $test = explode('-','one-two-three-four-five');
> $view = new Array();
> foreach($test as $boo => $foo){
> $view[$boo] = $foo;
> }
> print_r($view);
heheheh
i can write your solution a bit simpler
$view = $test;
DONE - but your solution is wrong
correct solution:
$view = array_combine($test, $test);
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl
2be || !2be $this => mysql_query(); >> Stay informed about: Query on explode() |
|
| Back to top |
|
 |  |
External

Since: Oct 03, 2006 Posts: 45
|
(Msg. 6) Posted: Mon Oct 16, 2006 5:37 pm
Post subject: Re: Query on explode() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hmm NurAzije wrote:
> Try this one, this will work :
> ---------------------------------------------------
> $test = explode('-','one-two-three-four-five');
> $view = new Array();
> foreach($test as $boo => $foo){
> $view[$foo] = $foo; // typing error, do it like this
> }
>
> print_r($view);
still too much of lines ... try array_combine
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl
2be || !2be $this => mysql_query(); >> Stay informed about: Query on explode() |
|
| Back to top |
|
 |  |
External

Since: Oct 16, 2005 Posts: 174
|
(Msg. 7) Posted: Tue Oct 17, 2006 2:40 am
Post subject: Re: Query on explode() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
..:[ ikciu ]:. wrote:
> Hmm NurAzije wrote:
>> Try this one, this will work :
>> ---------------------------------------------------
>> $test = explode('-','one-two-three-four-five');
>> $view = new Array();
>> foreach($test as $boo => $foo){
>> $view[$foo] = $foo; // typing error, do it like this
>> }
>>
>> print_r($view);
>
> still too much of lines ... try array_combine
Which Jan-Willem already said, and stated that it doesn't work on PHP < 5.
You seem to miss that the poster is trying to give a solution for PHP4.
About the question why the OP would want an array like this, it's beyond
me. I cannot see any advantage, but then again, I don't know what he's
trying to accomplish
Grtz,
--
Rik Wasmus >> Stay informed about: Query on explode() |
|
| Back to top |
|
 |  |
External

Since: Oct 03, 2006 Posts: 45
|
(Msg. 8) Posted: Tue Oct 17, 2006 4:19 am
Post subject: Re: Query on explode() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
Hmm Rik wrote:
> Which Jan-Willem already said, and stated that it doesn't work on PHP
> < 5. You seem to miss that the poster is trying to give a solution
> for PHP4.
ofc, but if some1 didn't write what php does he use i try to answer with
that php what i actualy use
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl
2be || !2be $this => mysql_query(); >> Stay informed about: Query on explode() |
|
| Back to top |
|
 |  |
External

Since: Oct 16, 2006 Posts: 8
|
(Msg. 9) Posted: Wed Oct 18, 2006 12:09 am
Post subject: Re: Query on explode() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
|
|
| Back to top |
|
 |  |
External

Since: Oct 16, 2005 Posts: 174
|
(Msg. 10) Posted: Wed Oct 18, 2006 2:42 am
Post subject: Re: Query on explode() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?)
|
|
|
..:[ ikciu ]:. wrote:
> Hmm Rik wrote:
>> Which Jan-Willem already said, and stated that it doesn't work on PHP
>> < 5. You seem to miss that the poster is trying to give a solution
>> for PHP4.
>
> ofc, but if some1 didn't write what php does he use i try to answer
> with that php what i actualy use
It's someone, I thought...
First of all, a lot of hosting companies still use PHP4.
Second of all, why do you keep insisting on giving an answer for PHP5,
which was already given 2 hours before your first post in the thread, as
the very first reply on the OP?
Grtz,
--
Rik Wasmus >> Stay informed about: Query on explode() |
|
| Back to top |
|
 |  |
| Related Topics: | explode - Hi All, I'm trying to use explode to separate the result of a textual file, but it explode me only the first row. the foo.txt is pippo pluto pluto pippo pippo pippo .... I use this script found in http://it2.php.net/manual/en/function.explode.php ..
explode() - I generate a text file created by a Memo Field in a Delphi application. This gets uploaded to my web server to populate a MySql database table. The text file uses the '|' (vertical bar) as a delimiter. A typical .txt file looks like this: 1234|4567|My...
Query Help - I have four fields, "name", "date", "task", and "title" - and am trying to PHP code where if I click 'All', all rows for 'Bob' followed by all rows in a MySQL datebase for 'Jim' and then all rows for 'Joe' would be...
Query - Ok, maybe I do not know how to search. But, putting MYSQL into Google's Group Search does not return any MySQL groups....go figure. So, the next best place......I have this query in my PHP script: SELECT customer_count, DATE_FORMAT(customer_date,'%a')...
Using the $ character in query - Does anyone know a successful way to use the dollar sign character within a query and not generate an error? Here's what I'm trying to do... I have a query that successfully counts the number of records within a query as well as totalizes the dollar.. |
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
 |
|
|