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 9258771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:29:34+00:00 2026-06-18T12:29:34+00:00

I am using array_slice in PHP like so: if (isset($_GET[‘page’]) && !isset($no_pagination)) { $page_num

  • 0

I am using array_slice in PHP like so:

if (isset($_GET['page']) && !isset($no_pagination)) {
        $page_num = mysql_real_escape_string($_GET['page']);
        $limit_value_from = $page_num * 10;
        $limit_value_to = $limit_value_from + 10;
        $limit_query = $limit_value_from.", ".$limit_value_to;
    }

if (!isset($no_pagination) && isset($limit_query)) {
        $usernames_new = array_splice($usernames, $limit_query);
        $usernames = $usernames_new;
    }

When I run the script it gives me this error: A non well formed numeric value encountered. When I echo the $limit_query string it gives me the correct 0, 10 10, 20 20, 30 values, and if I manually enter 0, 10 10, 20 etc. into the function it works fine. Why is this error happening even though it is properly formatted?

Note: When I place the @ symbol before the array splice line the code works fine… Just wanted to know why this error is occurring.

  • 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-06-18T12:29:35+00:00Added an answer on June 18, 2026 at 12:29 pm

    You look to be passing the wrong arguments for that method. The second argument is an INT.

    array array_slice ( array $array , int $offset [, int $length = NULL [, bool $preserve_keys = false ]] )
    

    Try this:

    $usernames_new = array_splice($usernames, $limit_value_from, $limit_value_to);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How do I delete a specific item by using array_splice / array_slice in PHP?
Using PHP, let's say I have this string: $letters = abcde; I would like
I am using the following snippet: implode(' ', array_slice(explode(' ', $sentence), 0, 10)); The
I am using PHP with IMAP. I need to retrieve the 20 most new
I am attempting to make a pie chart using a php file that gets
I am coding a PHP foreach loop. I am using the following code to
I'm using the gchart php wrapper from http://code.google.com/p/gchartphp/ . This is a question for
Using PHP, how I can I parse a JSON object with an array given
I'm using PHP to process uploads of .jpg, .gif, .jpeg, .png, .zip and .rar
I'm trying to write a string looking like this using go's template system: (p1,

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.