Jump to content

[SOLVED] Array to String


monkeypaw201

Recommended Posts

Is there a way to convert array to string? I'm not sure thats what I need, but something isn't working.. what step did i overlook?

 

<?php
#Link files into variables
$vatsim_file = file($vatsim);
$metacraft_file = file($metacraft);
$fsproshop_file = file($fsproshop);

#Get the last UPDATE variable
$vatsim_time = substr($vatsim_file,2543,14);
$metacraft_time = substr($metacraft_file,2543,14);
$fsproshop_time = substr($fsproshop_file,2543,14);
?>

 

Outputs:

 

Notice: Array to string conversion in /incoming.php on line 23

 

Notice: Array to string conversion in /incoming.php on line 24

 

Notice: Array to string conversion in /incoming.php on line 25

Link to comment
Share on other sites

Well, file() reads a file as an array and substr() expects a string object. Not sure what you are trying to accomplish, but you could use implode() to convert the file contents into a string or, probably better, use file_get_contents() to read the file as a string to begin with.

 

<?php
#Link files into variables
$vatsim_file = file_get_contents($vatsim);
$metacraft_file = file_get_contents($metacraft);
$fsproshop_file = file_get_contents($fsproshop);

#Get the last UPDATE variable
$vatsim_time = substr($vatsim_file,2543,14);
$metacraft_time = substr($metacraft_file,2543,14);
$fsproshop_time = substr($fsproshop_file,2543,14);
?>

Link to comment
Share on other sites

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.