Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6376159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:42:33+00:00 2026-05-25T01:42:33+00:00

I have a PHP array with URL’s that I would like to keep hidden

  • 0

I have a PHP array with URL’s that I would like to keep hidden (or at least more difficult to copy)
I need to convert this array to a JS array.
Is it possible without writing the items in JS?

So NOT like in following example where the URL’s can be found in the source…

<?php
    $arr = array("http://foo.com","http://bar.com","http://baz.com"); 
?>

<script>
    var newArr = new Array("<?php echo implode(',' ,$arr); ?>");
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:42:34+00:00Added an answer on May 25, 2026 at 1:42 am

    If you want to make the urls unreadable you can encode each character to \xnn escape sequence:

    <?php
        $arr = array( "http://foo.com","http://bar.com","http://baz.com" ); 
        $encodedArr = array();
        foreach( $arr as $url ) {
            $encodedUrl = '';
            for( $i = 0; $i < strlen( $url ); ++$i ) {
                $encodedUrl .= '\\x'.str_pad( 
                      sprintf( '%x', ord( $url[$i] ) ),
                      2, STR_PAD_LEFT );
            }
            $encodedArr[] = '"'.$encodedUrl.'"';
        }
    ?>
    <script type="text/javascript">
        var newArr = [ <?php echo implode(',' ,$encodedArr); ?> ];
        alert( newArr[0] );
    </script>
    

    the written javascript will look like this:

    var newArr = [ "\x68\x74\x74\x70\x3a\x2f\x2f\x66\x6f\x6f\x2e\x63\x6f\x6d","\x68\x74\x74\x70\x3a\x2f\x2f\x62\x61\x72\x2e\x63\x6f\x6d","\x68\x74\x74\x70\x3a\x2f\x2f\x62\x61\x7a\x2e\x63\x6f\x6d" ];
    alert( newArr[0] );
    

    but will alert http://foo.com

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a php array that has a bunch of data that I need
i have php function that parses a xml url and gives me an array.this
I have the following url /dir1/dir2/page.php I need to generate a an array of
I have a PHP array which looks like this example: $array[0][0] = 'apples'; $array[0][1]
I have a PHP 2D array, many keys, each with one value, I need
I have a php file somejson.php that echos a json encoded array {jsonone:first json,jsontwo:second
how to send array through url in PHP? I have an array of product
So I have a PHP class called router that takes the URL and explodes
I have this link: <a href=<?php echo $this->url(array('controller'=>'index','action'=>'form'),NULL,TRUE);?>> Form </a> With this I get
I have my Zend_Navigation loaded from a PHP array (but that's irrelevant...) and I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.