Jump to content

Recommended Posts

Hi sorry silly question, bit stuck on

 

Basically I am writing some code to reformat a string that comes in with lots of spaces. I have to be a little clever in my program as some of the column headers dont quite match with the content below (sometimes out by 1 char).

 

The question is basically however: -

 

Lets say

$String = "This is a test" ;

and i then do

$out = "" ;

$out[0] = $String[0] ;

$out[1] = $String[1] ;

$out[2] = $String[2] ;

$out[3] = $String[3] ;

 

If I: -

print("Output " . $out) ;

 

it says Array, but I want it to print "This"

 

 

I know this is something silly but dont want to use print_r etc, is there a way of change $out array back to a normal string

 

Comments please!

Link to comment
https://forums.phpfreaks.com/topic/88404-basic-question-on-arrays-strings/
Share on other sites

is there a way of change $out array back to a normal string

 

I fail to see the point but....

 

<?php

$String = "This is a test";
$out = array();
$out[0] = $String[0];
$out[1] = $String[1];
$out[2] = $String[2];
$out[3] = $String[3];
echo implode(' ', $out);

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.