php problem

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

jevin94
New php-forum User
New php-forum User
Posts: 9
Joined: Fri Mar 29, 2013 10:02 am
Contact:

php problem

Postby jevin94 » Tue Apr 09, 2013 6:02 am

Array ( [0] => hello every one this is my ne [1] => w post )

this is one of the output of print_r(str_split($f)))

so how can i remove Array "( [0] =>" and "[1] =>" and all this type of words...

johnj
php-forum Super User
php-forum Super User
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: php problem

Postby johnj » Tue Apr 09, 2013 8:30 pm

Please read about array_pop() from the php manual
http://php.net/manual/en/function.array-pop.php

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: php problem

Postby seandisanti » Tue Apr 09, 2013 10:31 pm

alternatively you could do it like:

Code: Select all


$variable 
= array('this is some arbitar','y text for an',' example.');
$output '';
foreach (
$variable as $fragment){
$output.=$fragment;
}
echo 
$output;
 

jevin94
New php-forum User
New php-forum User
Posts: 9
Joined: Fri Mar 29, 2013 10:02 am
Contact:

Re: php problem

Postby jevin94 » Fri Apr 12, 2013 8:51 am

johnj wrote:Please read about array_pop() from the php manual
http://php.net/manual/en/function.array-pop.php



I dont want to remove the element of the array, i want to remove just text "Array" as mentioned in my problem.

jevin94
New php-forum User
New php-forum User
Posts: 9
Joined: Fri Mar 29, 2013 10:02 am
Contact:

Re: php problem

Postby jevin94 » Fri Apr 12, 2013 8:53 am

seandisanti wrote:alternatively you could do it like:

Code: Select all


$variable 
= array('this is some arbitar','y text for an',' example.');
$output = '';
foreach ($variable as $fragment){
$output.=$fragment;
}
echo $output;


What is the value of $fragment?

seandisanti
php-forum Fan User
php-forum Fan User
Posts: 838
Joined: Mon Oct 01, 2012 12:32 pm

Re: php problem

Postby seandisanti » Fri Apr 12, 2013 11:37 am

It depends on the iteration. on each time through the loop, $fragment contains the value from a different index in the array


Return to “PHP coding => General”

Who is online

Users browsing this forum: No registered users and 2 guests

cron